<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: datatable   DataTable.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">

	<div id="hd">
        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
        <h3>DataTable Widget&nbsp; <span class="subtitle">2.3.1</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_datatable.html">datatable</a>
                
                 &gt; DataTable.js (source view) 
            </p>

	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form name="yui-classopts-form">
    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 #classopts { display:none; }
                        </style>
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c"> * The DataTable widget provides a progressively enhanced DHTML control for</span>
<span class="c"> * displaying tabular data across A-grade browsers.</span>
<span class="c"> *</span>
<span class="c"> * @module datatable</span>
<span class="c"> * @requires yahoo, dom, event, datasource</span>
<span class="c"> * @optional dragdrop</span>
<span class="c"> * @title DataTable Widget</span>
<span class="c"> * @beta</span>
<span class="c"> */</span>

<span class="c">/****************************************************************************/</span>
<span class="c">/****************************************************************************/</span>
<span class="c">/****************************************************************************/</span>

<span class="c">/**</span>
<span class="c"> * DataTable class for the YUI DataTable widget.</span>
<span class="c"> *</span>
<span class="c"> * @namespace YAHOO.widget</span>
<span class="c"> * @class DataTable</span>
<span class="c"> * @uses YAHOO.util.EventProvider</span>
<span class="c"> * @constructor</span>
<span class="c"> * @param elContainer {HTMLElement} Container element for the TABLE.</span>
<span class="c"> * @param aColumnDefs {Object[]} Array of object literal Column definitions.</span>
<span class="c"> * @param oDataSource {YAHOO.util.DataSource} DataSource instance.</span>
<span class="c"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">,</span><span class="nx">aColumnDefs</span><span class="o">,</span><span class="nx">oDataSource</span><span class="o">,</span><span class="nx">oConfigs</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Internal vars</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">_nCount</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_sName</span> <span class="o">=</span> <span class="s2">&quot;instance&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="s2">&quot;yui-dt&quot;</span><span class="o">+</span><span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span><span class="o">;</span>

    <span class="c">// Initialize container element</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initContainerEl</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid container element&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Initialize configs</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initConfigs</span><span class="o">(</span><span class="nx">oConfigs</span><span class="o">);</span>

    <span class="c">// Initialize ColumnSet</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initColumnSet</span><span class="o">(</span><span class="nx">aColumnDefs</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid ColumnSet&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    
    <span class="c">// Initialize RecordSet</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initRecordSet</span><span class="o">();</span>
    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid RecordSet&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Initialize DataSource</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initDataSource</span><span class="o">(</span><span class="nx">oDataSource</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid DataSource&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Progressive enhancement special case</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">.</span><span class="nx">dataType</span> <span class="o">==</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DataSource</span><span class="o">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">.</span><span class="nx">sendRequest</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;initialRequest&quot;</span><span class="o">),</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDataReturnEnhanceTable</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="c">// Initialize DOM elements</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_initTableEl</span><span class="o">();</span>
        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span> <span class="o">||</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span> <span class="o">||</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid DOM elements&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Call Element&#39;s constructor after DOM elements are created</span>
<span class="c"></span>        <span class="c">// but *before* table is populated with data</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span><span class="o">);</span>
        
        <span class="c">//HACK: Set the Paginator values here via updatePaginator</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Send out for data in an asynchronous request</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">.</span><span class="nx">sendRequest</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;initialRequest&quot;</span><span class="o">),</span> <span class="k">this</span><span class="o">.</span><span class="nx">onDataReturnInitializeTable</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="c">// Initialize inline Cell editing</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initCellEditorEl</span><span class="o">();</span>

    <span class="c">// Initialize Column sort</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initColumnSort</span><span class="o">();</span>

    <span class="c">// Initialize DOM event listeners</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initDomEvents</span><span class="o">();</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">_nCount</span><span class="o">++;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable initialized&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Element</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Element</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Missing dependency: YAHOO.util.Element&quot;</span><span class="o">,</span><span class="s2">&quot;error&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">}</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Superclass methods</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Implementation of Element&#39;s abstract method. Sets up config values.</span>
<span class="c"> *</span>
<span class="c"> * @method initAttributes</span>
<span class="c"> * @param oConfigs {Object} (Optional) Object literal definition of configuration values.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">initAttributes</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oConfigs</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">oConfigs</span> <span class="o">=</span> <span class="nx">oConfigs</span> <span class="o">||</span> <span class="o">{};</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initAttributes</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfigs</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">    * @attribute summary</span>
<span class="c">    * @description Value for the SUMMARY attribute.</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;summary&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">sSummary</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">summary</span> <span class="o">=</span> <span class="nx">sSummary</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute selectionMode</span>
<span class="c">    * @description Specifies row or cell selection mode. Accepts the following strings:</span>
<span class="c">    *    &lt;dl&gt;</span>
<span class="c">    *      &lt;dt&gt;&quot;standard&quot;&lt;/dt&gt;</span>
<span class="c">    *      &lt;dd&gt;Standard row selection with support for modifier keys to enable</span>
<span class="c">    *      multiple selections.&lt;/dd&gt;</span>
<span class="c">    *</span>
<span class="c">    *      &lt;dt&gt;&quot;single&quot;&lt;/dt&gt;</span>
<span class="c">    *      &lt;dd&gt;Row selection with modifier keys disabled to not allow</span>
<span class="c">    *      multiple selections.&lt;/dd&gt;</span>
<span class="c">    *</span>
<span class="c">    *      &lt;dt&gt;&quot;singlecell&quot;&lt;/dt&gt;</span>
<span class="c">    *      &lt;dd&gt;Cell selection with modifier keys disabled to not allow</span>
<span class="c">    *      multiple selections.&lt;/dd&gt;</span>
<span class="c">    *</span>
<span class="c">    *      &lt;dt&gt;&quot;cellblock&quot;&lt;/dt&gt;</span>
<span class="c">    *      &lt;dd&gt;Cell selection with support for modifier keys to enable multiple</span>
<span class="c">    *      selections in a block-fashion, like a spreadsheet.&lt;/dd&gt;</span>
<span class="c">    *</span>
<span class="c">    *      &lt;dt&gt;&quot;cellrange&quot;&lt;/dt&gt;</span>
<span class="c">    *      &lt;dd&gt;Cell selection with support for modifier keys to enable multiple</span>
<span class="c">    *      selections in a range-fashion, like a calendar.&lt;/dd&gt;</span>
<span class="c">    *    &lt;/dl&gt;</span>
<span class="c">    *</span>
<span class="c">    * @default &quot;standard&quot;</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;selectionMode&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="s2">&quot;standard&quot;</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute initialRequest</span>
<span class="c">    * @description Defines the initial request that gets sent to the DataSource.</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;initialRequest&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute sortedBy</span>
<span class="c">    * @description Object literal provides metadata for initial sort values if</span>
<span class="c">    * data will arrive pre-sorted:</span>
<span class="c">    * &lt;dl&gt;</span>
<span class="c">    *     &lt;dt&gt;sortedBy.key&lt;/dt&gt;</span>
<span class="c">    *     &lt;dd&gt;{String} Key of sorted Column&lt;/dd&gt;</span>
<span class="c">    *     &lt;dt&gt;sortedBy.dir&lt;/dt&gt;</span>
<span class="c">    *     &lt;dd&gt;{String} Initial sort direction, either &quot;asc&quot; or &quot;desc&quot;&lt;/dd&gt;</span>
<span class="c">    * &lt;/dl&gt;</span>
<span class="c">    * @type Object</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;sortedBy&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        <span class="c">// TODO: accepted array for nested sorts</span>
<span class="c"></span>        <span class="nx">validator</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="o">(</span><span class="nx">oNewSortedBy</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>
        <span class="o">},</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Remove ASC/DESC from TH</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">oOldSortedBy</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;sortedBy&quot;</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">oOldSortedBy</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oOldSortedBy</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">oOldSortedBy</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">oldColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">oOldSortedBy</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>
                <span class="k">var</span> <span class="nx">oldThEl</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getThEl</span><span class="o">(</span><span class="nx">oldColumn</span><span class="o">);</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">oldThEl</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">);</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">oldThEl</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span><span class="o">);</span>
            <span class="o">}</span>
            
            <span class="c">// Set ASC/DESC on TH</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">column</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">column</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">column</span> <span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">column</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">newClass</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oNewSortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">!=</span> <span class="s2">&quot;asc&quot;</span><span class="o">))</span> <span class="o">?</span>
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span> <span class="o">:</span>
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">;</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">column</span><span class="o">.</span><span class="nx">getId</span><span class="o">(),</span> <span class="nx">newClass</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute paginator</span>
<span class="c">    * @description Object literal of pagination values.</span>
<span class="c">    * @default &lt;br&gt;</span>
<span class="c">    *   { containers:[], // UI container elements &lt;br&gt;</span>
<span class="c">    *   rowsPerPage:500, // 500 rows &lt;br&gt;</span>
<span class="c">    *   currentPage:1,  // page one &lt;br&gt;</span>
<span class="c">    *   pageLinks:0,    // show all links &lt;br&gt;</span>
<span class="c">    *   pageLinksStart:1, // first link is page 1 &lt;br&gt;</span>
<span class="c">    *   dropdownOptions:null, // no dropdown &lt;br&gt;</span>
<span class="c">    *   links: [], // links elements &lt;br&gt;</span>
<span class="c">    *   dropdowns: [] } //dropdown elements</span>
<span class="c">    * </span>
<span class="c">    * @type Object</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="o">{</span>
            <span class="nx">rowsPerPage</span><span class="o">:</span><span class="m">500</span><span class="o">,</span> <span class="c">// 500 rows per page</span>
<span class="c"></span>            <span class="nx">currentPage</span><span class="o">:</span><span class="m">1</span><span class="o">,</span>  <span class="c">// show page one</span>
<span class="c"></span>            <span class="nx">startRecordIndex</span><span class="o">:</span><span class="m">0</span><span class="o">,</span> <span class="c">// start with first Record</span>
<span class="c"></span>            <span class="nx">totalRecords</span><span class="o">:</span><span class="m">0</span><span class="o">,</span> <span class="c">// how many Records total</span>
<span class="c"></span>            <span class="nx">totalPages</span><span class="o">:</span><span class="m">0</span><span class="o">,</span> <span class="c">// how many pages total</span>
<span class="c"></span>            <span class="nx">rowsThisPage</span><span class="o">:</span><span class="m">0</span><span class="o">,</span> <span class="c">// how many rows this page</span>
<span class="c"></span>            <span class="nx">pageLinks</span><span class="o">:</span><span class="m">0</span><span class="o">,</span>    <span class="c">// show all links</span>
<span class="c"></span>            <span class="nx">pageLinksStart</span><span class="o">:</span><span class="m">1</span><span class="o">,</span> <span class="c">// first link is page 1</span>
<span class="c"></span>            <span class="nx">dropdownOptions</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span> <span class="c">//no dropdown</span>
<span class="c"></span>            <span class="nx">containers</span><span class="o">:[],</span> <span class="c">// Paginator container element references</span>
<span class="c"></span>            <span class="nx">dropdowns</span><span class="o">:</span> <span class="o">[],</span> <span class="c">//dropdown element references,</span>
<span class="c"></span>            <span class="nx">links</span><span class="o">:</span> <span class="o">[]</span> <span class="c">// links elements</span>
<span class="c"></span>        <span class="o">},</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">oNewPaginator</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Check for incomplete set of values</span>
<span class="c"></span>                <span class="k">if</span><span class="o">((</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">currentPage</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">startRecordIndex</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">totalRecords</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">totalPages</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">rowsThisPage</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">pageLinks</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">pageLinksStart</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">dropdownOptions</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">containers</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">dropdowns</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">links</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">))</span> <span class="o">{</span>

                    <span class="c">// Validate each value</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">currentPage</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">startRecordIndex</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">totalRecords</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">totalPages</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">rowsThisPage</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">pageLinks</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">pageLinksStart</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">dropdownOptions</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">containers</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">dropdowns</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oNewPaginator</span><span class="o">.</span><span class="nx">links</span><span class="o">))</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute paginated</span>
<span class="c">    * @description True if built-in client-side pagination is enabled</span>
<span class="c">    * @default false</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;paginated&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">oParam</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">oPaginator</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">);</span>
            <span class="k">var</span> <span class="nx">aContainerEls</span> <span class="o">=</span> <span class="nx">oPaginator</span><span class="o">.</span><span class="nx">containers</span><span class="o">;</span>
            <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
            
            <span class="c">// Paginator is enabled</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oParam</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// No containers found, create two from scratch</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// One before TABLE</span>
<span class="c"></span>                    <span class="k">var</span> <span class="nx">pag0</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">);</span>
                    <span class="nx">pag0</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-paginator0&quot;</span><span class="o">;</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">pag0</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGINATOR</span><span class="o">);</span>
                    <span class="nx">pag0</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">pag0</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">);</span>
                    <span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">pag0</span><span class="o">);</span>

                    <span class="c">// One after TABLE</span>
<span class="c"></span>                    <span class="k">var</span> <span class="nx">pag1</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">);</span>
                    <span class="nx">pag1</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-paginator1&quot;</span><span class="o">;</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">pag1</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGINATOR</span><span class="o">);</span>
                    <span class="nx">pag1</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">pag1</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">);</span>
                    <span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">pag1</span><span class="o">);</span>

                    <span class="c">// Add containers directly to tracker</span>
<span class="c"></span>                    <span class="k">this</span><span class="o">.</span><span class="nx">_configs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">.</span><span class="nx">value</span><span class="o">.</span><span class="nx">containers</span> <span class="o">=</span> <span class="o">[</span><span class="nx">pag0</span><span class="o">,</span> <span class="nx">pag1</span><span class="o">];</span>

                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="c">// Show each container</span>
<span class="c"></span>                    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="nx">aContainerEls</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span>

                <span class="c">// Links are enabled</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">oPaginator</span><span class="o">.</span><span class="nx">pageLinks</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">var</span> <span class="nx">aLinkEls</span> <span class="o">=</span> <span class="nx">oPaginator</span><span class="o">.</span><span class="nx">links</span><span class="o">;</span>
                    <span class="c">// No links containers found, create from scratch</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">aLinkEls</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="c">// Create one links container per Paginator container</span>
<span class="c"></span>                            <span class="k">var</span> <span class="nx">linkEl</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">);</span>
                            <span class="nx">linkEl</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-pagselect&quot;</span><span class="o">+</span><span class="nx">i</span><span class="o">;</span>
                            <span class="nx">linkEl</span> <span class="o">=</span> <span class="nx">aContainerEls</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">linkEl</span><span class="o">);</span>

                            <span class="c">// Add event listener</span>
<span class="c"></span>                            <span class="c">//TODO: anon fnc</span>
<span class="c"></span>                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">linkEl</span><span class="o">,</span><span class="s2">&quot;click&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_onPaginatorLinkClick</span><span class="o">,</span><span class="k">this</span><span class="o">);</span>

                             <span class="c">// Add directly to tracker</span>
<span class="c"></span>                            <span class="k">this</span><span class="o">.</span><span class="nx">_configs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">.</span><span class="nx">value</span><span class="o">.</span><span class="nx">links</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">linkEl</span><span class="o">);</span>
                       <span class="o">}</span>
                   <span class="o">}</span>
                <span class="o">}</span>

                <span class="c">// Show these options in the dropdown</span>
<span class="c"></span>                <span class="k">var</span> <span class="nx">dropdownOptions</span> <span class="o">=</span> <span class="nx">oPaginator</span><span class="o">.</span><span class="nx">dropdownOptions</span> <span class="o">||</span> <span class="o">[];</span>

                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="c">// Create one SELECT element per Paginator container</span>
<span class="c"></span>                    <span class="k">var</span> <span class="nx">selectEl</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;select&quot;</span><span class="o">);</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DROPDOWN</span><span class="o">);</span>
                    <span class="nx">selectEl</span> <span class="o">=</span> <span class="nx">aContainerEls</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">);</span>
                    <span class="nx">selectEl</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-pagselect&quot;</span><span class="o">+</span><span class="nx">i</span><span class="o">;</span>

                    <span class="c">// Add event listener</span>
<span class="c"></span>                    <span class="c">//TODO: anon fnc</span>
<span class="c"></span>                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">,</span><span class="s2">&quot;change&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_onPaginatorDropdownChange</span><span class="o">,</span><span class="k">this</span><span class="o">);</span>

                    <span class="c">// Add DOM reference directly to tracker</span>
<span class="c"></span>                   <span class="k">this</span><span class="o">.</span><span class="nx">_configs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">.</span><span class="nx">value</span><span class="o">.</span><span class="nx">dropdowns</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">);</span>

                    <span class="c">// Hide dropdown</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(!</span><span class="nx">oPaginator</span><span class="o">.</span><span class="nx">dropdownOptions</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">selectEl</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span>

                <span class="c">//TODO: fire paginatorDisabledEvent &amp; add to api doc</span>
<span class="c"></span>                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Paginator enabled&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="o">}</span>
            <span class="c">// Pagination is disabled</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="c">// Containers found</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Destroy or just hide?</span>
<span class="c"></span>                    
                    <span class="c">// Hide each container</span>
<span class="c"></span>                    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aContainerEls</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="nx">aContainerEls</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
                    <span class="o">}</span>

                    <span class="c">/*TODO?</span>
<span class="c">                    // Destroy each container</span>
<span class="c">                    for(i=0; i&lt;aContainerEls.length; i++) {</span>
<span class="c">                        YAHOO.util.Event.purgeElement(aContainerEls[i], true);</span>
<span class="c">                        aContainerEls.innerHTML = null;</span>
<span class="c">                        //TODO: remove container?</span>
<span class="c">                        // aContainerEls[i].parentNode.removeChild(aContainerEls[i]);</span>
<span class="c">                    }</span>
<span class="c">                    */</span>
                <span class="o">}</span>
                <span class="c">//TODO: fire paginatorDisabledEvent &amp; add to api doc</span>
<span class="c"></span>                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Paginator disabled&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute caption</span>
<span class="c">    * @description Value for the CAPTION element.</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;caption&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">sCaption</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Create CAPTION element</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elCaption</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_elCaption</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;caption&quot;</span><span class="o">));</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_elCaption</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;caption&quot;</span><span class="o">),</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Set CAPTION value</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_elCaption</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">sCaption</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">});</span>

    <span class="c">/**</span>
<span class="c">    * @attribute scrollable</span>
<span class="c">    * @description True if primary TBODY should scroll while THEAD remains fixed.</span>
<span class="c">    * When enabling this feature, captions cannot be used, and the following</span>
<span class="c">    * features are not recommended: inline editing, resizeable columns.</span>
<span class="c">    * @default false</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;scrollable&quot;</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">value</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">oParam</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">//TODO: validate agnst resizeable</span>
<span class="c"></span>            <span class="k">return</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">(</span><span class="nx">oParam</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                    <span class="c">// Not compatible with caption</span>
<span class="c"></span>                    <span class="o">!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;caption&quot;</span><span class="o">)));</span>
        <span class="o">},</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">oParam</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">oParam</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">//TODO: conf height</span>
<span class="c"></span>                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLABLE</span><span class="o">);</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLBODY</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLABLE</span><span class="o">);</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLBODY</span><span class="o">);</span>

            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">});</span>
<span class="o">};</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public constants</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Class name assigned to TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_TABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-table&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_TABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-table&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to header container elements within each TH element.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_HEADER</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-header&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADER</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-header&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the primary TBODY element.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_BODY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-body&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BODY</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-body&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the scrolling TBODY element of a fixed scrolling DataTable.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_SCROLLBODY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-scrollbody&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLBODY</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-scrollbody&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to display label elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_LABEL</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-label&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-label&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to resizer handle elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_RESIZER</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-resizer&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_RESIZER</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-resizer&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to Editor container elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_EDITOR</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-editor&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EDITOR</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-editor&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to paginator container elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_PAGINATOR</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-paginator&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGINATOR</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-paginator&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to page number indicators.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_PAGE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-page&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-page&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to default indicators.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_DEFAULT</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-default&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DEFAULT</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-default&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to previous indicators.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_PREVIOUS</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-previous&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVIOUS</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-previous&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned next indicators.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_NEXT</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-next&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXT</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-next&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to first elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_FIRST</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-first&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-first&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to last elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_LAST</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-last&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-last&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to even elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_EVEN</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-even&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-even&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to odd elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_ODD</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-odd&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-odd&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to selected elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_SELECTED</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-selected&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-selected&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to highlighted elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_HIGHLIGHTED</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-highlighted&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-highlighted&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to disabled elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_DISABLED</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-disabled&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DISABLED</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-disabled&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to empty indicators.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_EMPTY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-empty&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-empty&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to loading indicatorx.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_LOADING</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-loading&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LOADING</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-loading&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to error indicators.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_ERROR</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-error&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ERROR</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-error&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to editable elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_EDITABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-editable&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EDITABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-editable&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to scrollable elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_SCROLLABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-scrollable&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-scrollable&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to sortable elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_SORTABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-sortable&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-sortable&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to ascending elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_ASC</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-asc&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-asc&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to descending elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_DESC</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-desc&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-desc&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to BUTTON elements and/or container elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_BUTTON</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-button&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BUTTON</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-button&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to INPUT TYPE=CHECKBOX elements and/or container elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_CHECKBOX</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-checkbox&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_CHECKBOX</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-checkbox&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to SELECT elements and/or container elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_DROPDOWN</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-dropdown&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DROPDOWN</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-dropdown&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to INPUT TYPE=RADIO elements and/or container elements.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.CLASS_RADIO</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-radio&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_RADIO</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-radio&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Message to display if DataTable has no data.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.MSG_EMPTY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;No records found.&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span> <span class="o">=</span> <span class="s2">&quot;No records found.&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Message to display while DataTable is loading data.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.MSG_LOADING</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;Loading data...&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_LOADING</span> <span class="o">=</span> <span class="s2">&quot;Loading data...&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Message to display while DataTable has data error.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable.MSG_ERROR</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;Data error.&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_ERROR</span> <span class="o">=</span> <span class="s2">&quot;Data error.&quot;</span><span class="o">;</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private member variables</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Internal class variable for indexing multiple DataTable instances.</span>
<span class="c"> *</span>
<span class="c"> * @property DataTable._nCount</span>
<span class="c"> * @type Number</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">_nCount</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Index assigned to instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _nIndex</span>
<span class="c"> * @type Number</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_nIndex</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Counter for IDs assigned to TR elements.</span>
<span class="c"> *</span>
<span class="c"> * @property _nTrCount</span>
<span class="c"> * @type Number</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_nTrCount</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Unique name assigned to instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _sName</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sName</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the container element for the DataTable instance into which</span>
<span class="c"> * the TABLE element gets created.</span>
<span class="c"> *</span>
<span class="c"> * @property _elContainer</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elContainer</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the CAPTION element for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _elCaption</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elCaption</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the TABLE element for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _elTable</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elTable</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the THEAD element for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _elThead</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elThead</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the primary TBODY element for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _elTbody</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elTbody</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the secondary TBODY element used to display DataTable messages.</span>
<span class="c"> *</span>
<span class="c"> * @property _elMsgTbody</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elMsgTbody</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the secondary TBODY element&#39;s single TR element used to display DataTable messages.</span>
<span class="c"> *</span>
<span class="c"> * @property _elMsgTbodyRow</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elMsgTbodyRow</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DOM reference to the secondary TBODY element&#39;s single TD element used to display DataTable messages.</span>
<span class="c"> *</span>
<span class="c"> * @property _elMsgTbodyCell</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elMsgTbodyCell</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * DataSource instance for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _oDataSource</span>
<span class="c"> * @type YAHOO.util.DataSource</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oDataSource</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ColumnSet instance for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _oColumnSet</span>
<span class="c"> * @type YAHOO.widget.ColumnSet</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oColumnSet</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * RecordSet instance for the DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _oRecordSet</span>
<span class="c"> * @type YAHOO.widget.RecordSet</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oRecordSet</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ID string of first label link element of the current DataTable page, if any.</span>
<span class="c"> * Used for focusing sortable Columns with TAB.</span>
<span class="c"> *</span>
<span class="c"> * @property _sFirstLabelLinkId</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sFirstLabelLinkId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ID string of first TR element of the current DataTable page.</span>
<span class="c"> *</span>
<span class="c"> * @property _sFirstTrId</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sFirstTrId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ID string of the last TR element of the current DataTable page.</span>
<span class="c"> *</span>
<span class="c"> * @property _sLastTrId</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sLastTrId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
































<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private methods</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Sets focus on the given element.</span>
<span class="c"> *</span>
<span class="c"> * @method _focusEl</span>
<span class="c"> * @param el {HTMLElement} Element.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_focusEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">el</span> <span class="o">=</span> <span class="nx">el</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
    <span class="c">// http://developer.mozilla.org/en/docs/index.php?title=Key-navigable_custom_DHTML_widgets</span>
<span class="c"></span>    <span class="c">// The timeout is necessary in both IE and Firefox 1.5, to prevent scripts from doing</span>
<span class="c"></span>    <span class="c">// strange unexpected things as the user clicks on buttons and other controls.</span>
<span class="c"></span>    <span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span> <span class="nx">el</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span> <span class="o">},</span><span class="m">0</span><span class="o">);</span>
<span class="o">};</span>





<span class="c">// INIT FUNCTIONS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Initializes container element.</span>
<span class="c"> *</span>
<span class="c"> * @method _initContainerEl</span>
<span class="c"> * @param elContainer {HTMLElement | String} HTML DIV element by reference or ID.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initContainerEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elContainer</span> <span class="o">&amp;&amp;</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elContainer</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;div&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Initializes object literal of config values.</span>
<span class="c"> *</span>
<span class="c"> * @method _initConfigs</span>
<span class="c"> * @param oConfig {Object} Object literal of config values.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initConfigs</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oConfigs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oConfigs</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oConfigs</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">!=</span> <span class="nb">Object</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oConfigs</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Invalid configs&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
        <span class="c">// Backward compatibility</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">(</span><span class="nx">oConfigs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable&#39;s paginator model has been revised&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; -- please refer to the documentation for implementation&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; details&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span> <span class="o">=</span> <span class="nx">oConfigs</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Initializes ColumnSet.</span>
<span class="c"> *</span>
<span class="c"> * @method _initColumnSet</span>
<span class="c"> * @param aColumnDefs {Object[]} Array of object literal Column definitions.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initColumnSet</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">aColumnDefs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">aColumnDefs</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span> <span class="o">=</span>  <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">ColumnSet</span><span class="o">(</span><span class="nx">aColumnDefs</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Backward compatibility</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">aColumnDefs</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">ColumnSet</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span> <span class="o">=</span>  <span class="nx">aColumnDefs</span><span class="o">;</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable&#39;s constructor now requires an array&quot;</span> <span class="o">+</span>
        <span class="s2">&quot; of object literal Column definitions instead of a ColumnSet instance&quot;</span><span class="o">,</span>
        <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Initializes DataSource.</span>
<span class="c"> *</span>
<span class="c"> * @method _initDataSource</span>
<span class="c"> * @param oDataSource {YAHOO.util.DataSource} DataSource instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initDataSource</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oDataSource</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oDataSource</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oDataSource</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DataSource</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span> <span class="o">=</span> <span class="nx">oDataSource</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="c">// Backward compatibility</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">tmpTable</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">tmpContainer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
        <span class="c">// Peek in container child nodes to see if TABLE already exists</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">tmpContainer</span><span class="o">.</span><span class="nx">hasChildNodes</span><span class="o">())</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">tmpChildren</span> <span class="o">=</span> <span class="nx">tmpContainer</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">;</span>
            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">tmpChildren</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">tmpChildren</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> <span class="nx">tmpChildren</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">tmpTable</span> <span class="o">=</span> <span class="nx">tmpChildren</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">tmpTable</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">tmpFieldsArray</span> <span class="o">=</span> <span class="o">[];</span>
                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="nx">tmpFieldsArray</span><span class="o">.</span><span class="nx">push</span><span class="o">({</span><span class="nx">key</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">key</span><span class="o">});</span>
                <span class="o">}</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DataSource</span><span class="o">(</span><span class="nx">tmpTable</span><span class="o">);</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DataSource</span><span class="o">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="o">;</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">.</span><span class="nx">responseSchema</span> <span class="o">=</span> <span class="o">{</span><span class="nx">fields</span><span class="o">:</span> <span class="nx">tmpFieldsArray</span><span class="o">};</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Null DataSource for progressive enhancement from&quot;</span> <span class="o">+</span>
                <span class="s2">&quot; markup has been deprecated&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Initializes RecordSet.</span>
<span class="c"> *</span>
<span class="c"> * @method _initRecordSet</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initRecordSet</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">reset</span><span class="o">();</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">RecordSet</span><span class="o">();</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Creates HTML markup for TABLE, THEAD and TBODY elements.</span>
<span class="c"> *</span>
<span class="c"> * @method _initTableEl</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initTableEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">// Clear the container</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

    <span class="c">// Create TABLE</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;table&quot;</span><span class="o">));</span>
    <span class="k">var</span> <span class="nx">elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
    <span class="nx">elTable</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
    <span class="nx">elTable</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-table&quot;</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_TABLE</span><span class="o">);</span>

    <span class="c">// Create THEAD</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initTheadEl</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">);</span>


    <span class="c">// Create TBODY for messages</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elMsgTbody</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tbody&quot;</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elMsgRow</span> <span class="o">=</span> <span class="nx">elMsgTbody</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">));</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elMsgRow</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elMsgRow</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgRow</span> <span class="o">=</span> <span class="nx">elMsgRow</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elMsgCell</span> <span class="o">=</span> <span class="nx">elMsgRow</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;td&quot;</span><span class="o">));</span>
    <span class="nx">elMsgCell</span><span class="o">.</span><span class="nx">colSpan</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elMsgCell</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elMsgCell</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTd</span> <span class="o">=</span> <span class="nx">elMsgCell</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTbody</span> <span class="o">=</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">elMsgTbody</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_LOADING</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LOADING</span><span class="o">);</span>

    <span class="c">// Create TBODY for data</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span> <span class="o">=</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tbody&quot;</span><span class="o">));</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BODY</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Populates THEAD element with TH cells as defined by ColumnSet.</span>
<span class="c"> *</span>
<span class="c"> * @method _initTheadEl</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initTheadEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">,</span> <span class="nx">colId</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oColumnSet</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_sFirstLabelLinkId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    
    <span class="c">// Create THEAD</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elThead</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;thead&quot;</span><span class="o">);</span>

    <span class="c">// Iterate through each row of Column headers...</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">colTree</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">tree</span><span class="o">;</span>
    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">colTree</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elTheadRow</span> <span class="o">=</span> <span class="nx">elThead</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">));</span>
        <span class="nx">elTheadRow</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-hdrow&quot;</span><span class="o">+</span><span class="nx">i</span><span class="o">;</span>

        <span class="k">var</span> <span class="nx">elTheadCell</span><span class="o">;</span>
        <span class="c">// ...and create THEAD cells</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">colTree</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">colTree</span><span class="o">[</span><span class="nx">i</span><span class="o">][</span><span class="nx">j</span><span class="o">];</span>
            <span class="nx">elTheadCell</span> <span class="o">=</span> <span class="nx">elTheadRow</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;th&quot;</span><span class="o">));</span>
            <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_initThEl</span><span class="o">(</span><span class="nx">elTheadCell</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">,</span><span class="nx">i</span><span class="o">,</span><span class="nx">j</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Set FIRST/LAST on THEAD rows</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">i</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">i</span> <span class="o">===</span> <span class="o">(</span><span class="nx">colTree</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">elThead</span><span class="o">);</span>

    <span class="c">// Set FIRST/LAST on THEAD cells using the values in ColumnSet headers array</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">aFirstHeaders</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">headers</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
    <span class="k">var</span> <span class="nx">aLastHeaders</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">headers</span><span class="o">[</span><span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">headers</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aFirstHeaders</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-col&quot;</span><span class="o">+</span><span class="nx">aFirstHeaders</span><span class="o">[</span><span class="nx">i</span><span class="o">]),</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aLastHeaders</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-col&quot;</span><span class="o">+</span><span class="nx">aLastHeaders</span><span class="o">[</span><span class="nx">i</span><span class="o">]),</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
    <span class="o">}</span>
    
    <span class="c">// Add Resizer only after DOM has been updated</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">foundDD</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DD</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">needDD</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">colKey</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getKey</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">elTheadCellId</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">());</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">resizeable</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">foundDD</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">//TODO: fix fixed width tables</span>
<span class="c"></span>                <span class="c">// Skip the last column for fixed-width tables</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span> <span class="o">||</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span> <span class="o">&amp;&amp;</span>
                        <span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">()</span> <span class="o">!=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)))</span> <span class="o">{</span>
                    <span class="c">// TODO: better way to get elTheadContainer</span>
<span class="c"></span>                    <span class="k">var</span> <span class="nx">elThContainer</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADER</span><span class="o">,</span><span class="s2">&quot;div&quot;</span><span class="o">,</span><span class="nx">elTheadCellId</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>
                    <span class="k">var</span> <span class="nx">elThResizer</span> <span class="o">=</span> <span class="nx">elThContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">));</span>
                    <span class="nx">elThResizer</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-resizer-&quot;</span> <span class="o">+</span> <span class="nx">colKey</span><span class="o">;</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elThResizer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_RESIZER</span><span class="o">);</span>
                    <span class="nx">oColumn</span><span class="o">.</span><span class="nx">ddResizer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">ColumnResizer</span><span class="o">(</span>
                            <span class="k">this</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">elTheadCellId</span><span class="o">,</span> <span class="nx">elThResizer</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">elThResizer</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
                    <span class="k">var</span> <span class="nx">cancelClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopPropagation</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                    <span class="o">};</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elThResizer</span><span class="o">,</span><span class="s2">&quot;click&quot;</span><span class="o">,</span><span class="nx">cancelClick</span><span class="o">);</span>
                <span class="o">}</span>
                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">//TODO: fix fixedWidth</span>
<span class="c"></span>                    <span class="c">//elThContainer.style.overflow = &quot;hidden&quot;;</span>
<span class="c"></span>                    <span class="c">//TODO: better way to get elTheadText</span>
<span class="c"></span>                    <span class="k">var</span> <span class="nx">elThLabel</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">,</span><span class="s2">&quot;span&quot;</span><span class="o">,</span><span class="nx">elTheadCellId</span><span class="o">))[</span><span class="m">0</span><span class="o">];</span>
                    <span class="nx">elThLabel</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">overflow</span> <span class="o">=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">needDD</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">needDD</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not find DragDrop dependancy for resizeable Columns&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Column headers for &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; keys created&quot;</span><span class="o">,</span><span class="s2">&quot;info&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Populates TH cell as defined by Column.</span>
<span class="c"> *</span>
<span class="c"> * @method _initThEl</span>
<span class="c"> * @param elTheadCell {HTMLElement} TH cell element reference.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column object.</span>
<span class="c"> * @param row {number} Row index.</span>
<span class="c"> * @param col {number} Column index.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initThEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elTheadCell</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">,</span><span class="nx">row</span><span class="o">,</span><span class="nx">col</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Clear out the cell of prior content</span>
<span class="c"></span>    <span class="c">// TODO: purgeListeners and other validation-related things</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">colKey</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getKey</span><span class="o">();</span>
    <span class="k">var</span> <span class="nx">colId</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>
    <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span> <span class="o">=</span> <span class="nx">colKey</span><span class="o">;</span>
    <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">yuiColumnId</span> <span class="o">=</span> <span class="nx">colId</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">abbr</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">abbr</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">abbr</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">width</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">width</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">width</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">var</span> <span class="nx">aCustomClasses</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">aCustomClasses</span> <span class="o">=</span> <span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">];</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">aCustomClasses</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">aCustomClasses</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aCustomClasses</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadCell</span><span class="o">,</span><span class="nx">aCustomClasses</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadCell</span><span class="o">,</span> <span class="s2">&quot;yui-dt-col-&quot;</span><span class="o">+</span><span class="nx">colKey</span><span class="o">);</span>
    
    <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">rowSpan</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getRowspan</span><span class="o">();</span>
    <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">colSpan</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getColspan</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">elTheadContainer</span> <span class="o">=</span> <span class="nx">elTheadCell</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;div&quot;</span><span class="o">));</span>
    <span class="nx">elTheadContainer</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-container&quot;</span> <span class="o">+</span> <span class="nx">colId</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadContainer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADER</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTheadLabel</span> <span class="o">=</span> <span class="nx">elTheadContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">));</span>
    <span class="nx">elTheadLabel</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-label&quot;</span> <span class="o">+</span> <span class="nx">colId</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadLabel</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">sLabel</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="k">label</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oColumn</span><span class="o">.</span><span class="k">label</span> <span class="o">:</span> <span class="nx">colKey</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortable</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elTheadCell</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTABLE</span><span class="o">);</span>
        <span class="c">//TODO: Make sortLink customizeable</span>
<span class="c"></span>        <span class="c">//TODO: Make title configurable</span>
<span class="c"></span>        <span class="c">//TODO: Separate label from an accessibility link that says</span>
<span class="c"></span>        <span class="c">// &quot;Click to sort ascending&quot; and push it offscreen</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sLabelLinkId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-labellink&quot;</span> <span class="o">+</span> <span class="nx">colId</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">sortLink</span> <span class="o">=</span> <span class="s2">&quot;?key=&quot;</span> <span class="o">+</span> <span class="nx">colKey</span><span class="o">;</span>
        <span class="nx">elTheadLabel</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;a id=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">sLabelLinkId</span> <span class="o">+</span> <span class="s2">&quot;\&quot; href=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">sortLink</span> <span class="o">+</span> <span class="s2">&quot;\&quot; title=\&quot;Click to sort\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTABLE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">sLabel</span> <span class="o">+</span> <span class="s2">&quot;&lt;/a&gt;&quot;</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_sFirstLabelLinkId</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_sFirstLabelLinkId</span> <span class="o">=</span> <span class="nx">sLabelLinkId</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">elTheadLabel</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">sLabel</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Creates HTML markup for Cell Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method _initCellEditorEl</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initCellEditorEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">// Attach Cell Editor container element to body</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elCellEditor</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;div&quot;</span><span class="o">);</span>
    <span class="nx">elCellEditor</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-celleditor&quot;</span><span class="o">;</span>
    <span class="nx">elCellEditor</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCellEditor</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EDITOR</span><span class="o">);</span>
    <span class="nx">elCellEditor</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">elCellEditor</span><span class="o">);</span>

    <span class="c">// Internal tracker of Cell Editor values</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">oCellEditor</span> <span class="o">=</span> <span class="o">{};</span>
    <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">container</span> <span class="o">=</span> <span class="nx">elCellEditor</span><span class="o">;</span>
    <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">isActive</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span> <span class="o">=</span> <span class="nx">oCellEditor</span><span class="o">;</span>

    <span class="c">// Handle ESC key</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="s2">&quot;editorKeydownEvent&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">e</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>

        <span class="c">// ESC hides Cell Editor</span>
<span class="c"></span>        <span class="k">if</span><span class="o">((</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">27</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">cancelCellEditor</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Initializes Column sorting.</span>
<span class="c"> *</span>
<span class="c"> * @method _initColumnSort</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initColumnSort</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="s2">&quot;headerCellClickEvent&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">onEventSortColumn</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Initializes DOM event listeners.</span>
<span class="c"> *</span>
<span class="c"> * @method _initDomEvents</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initDomEvents</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elThead</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTbody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">;</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentClick</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeydown</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;focus&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableFocus</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableMouseover</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableMouseout</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableMousedown</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableKeydown</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;keypress&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableKeypress</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="c">// Since we can&#39;t listen for click and dblclick on the same element...</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;dblclick&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTableDblclick</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elThead</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTheadClick</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTbody</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTbodyClick</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">,</span> <span class="s2">&quot;scroll&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onScroll</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span> <span class="c">// for IE</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTbody</span><span class="o">,</span> <span class="s2">&quot;scroll&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onScroll</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span> <span class="c">// for everyone else</span>
<span class="c"></span><span class="o">};</span>





































<span class="c">// DOM MUTATION FUNCTIONS</span>
<span class="c"></span>



<span class="c">/**</span>
<span class="c"> * Adds a TR element to the primary TBODY at the page row index if given, otherwise</span>
<span class="c"> * at the end of the page. Formats TD elements within the TR element using data</span>
<span class="c"> * from the given Record.</span>
<span class="c"> *</span>
<span class="c"> * @method _addTrEl</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param index {Number} (optional) The page row index at which to add the TR</span>
<span class="c"> * element.</span>
<span class="c"> * @return {String} ID of the added TR element, or null.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_addTrEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessage</span><span class="o">();</span>

    <span class="c">// It&#39;s an append if no index provided, or index is negative or too big</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">append</span> <span class="o">=</span> <span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">index</span> <span class="o">&lt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">||</span>
            <span class="o">(</span><span class="nx">index</span> <span class="o">&gt;=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">)))</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
            
    <span class="k">var</span> <span class="nx">oColumnSet</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oRecordSet</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">isSortedBy</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;sortedBy&quot;</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">sortedColKeyIndex</span>  <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">sortedDir</span><span class="o">,</span> <span class="nx">newClass</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">isSortedBy</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">sortedColKeyIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">column</span><span class="o">)</span> <span class="o">?</span>
                <span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">()</span> <span class="o">:</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">key</span><span class="o">).</span><span class="nx">getKeyIndex</span><span class="o">();</span>
        <span class="nx">sortedDir</span> <span class="o">=</span> <span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">dir</span><span class="o">;</span>
        <span class="nx">newClass</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortedDir</span> <span class="o">===</span> <span class="s2">&quot;desc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span> <span class="o">:</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="o">(</span><span class="nx">append</span><span class="o">)</span> <span class="o">?</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">))</span> <span class="o">:</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">),</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">index</span><span class="o">]);</span>

    <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-bdrow&quot;</span><span class="o">+</span><span class="k">this</span><span class="o">.</span><span class="nx">_nTrCount</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_nTrCount</span><span class="o">++;</span>
    <span class="nx">elRow</span><span class="o">.</span><span class="nx">yuiRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

    <span class="c">// Create TD cells</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;td&quot;</span><span class="o">));</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-cell&quot;</span><span class="o">+</span><span class="nx">j</span><span class="o">;</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getKey</span><span class="o">();</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">k</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">k</span><span class="o">&lt;</span><span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">headers</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">length</span><span class="o">;</span> <span class="nx">k</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">elCell</span><span class="o">.</span><span class="nx">headers</span> <span class="o">+=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">headers</span><span class="o">[</span><span class="nx">j</span><span class="o">][</span><span class="nx">k</span><span class="o">]</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="o">;</span>
        <span class="o">}</span>
        
        <span class="c">// For SF2 cellIndex bug: http://www.webreference.com/programming/javascript/ppk2/3.html</span>
<span class="c"></span>        <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiCellIndex</span> <span class="o">=</span> <span class="nx">j</span><span class="o">;</span>

        <span class="c">// Update UI</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">formatCell</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">);</span>

        <span class="c">// Set FIRST/LAST on TD</span>
<span class="c"></span>        <span class="k">if</span> <span class="o">(</span><span class="nx">j</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">j</span> <span class="o">===</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
        <span class="o">}</span>
        
        <span class="c">// Remove ASC/DESC</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span><span class="o">);</span>
        
        <span class="c">// Set ASC/DESC on TD</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">j</span> <span class="o">===</span> <span class="nx">sortedColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">newClass</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortedDir</span> <span class="o">===</span> <span class="s2">&quot;desc&quot;</span><span class="o">)</span> <span class="o">?</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span> <span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">newClass</span><span class="o">);</span>
        <span class="o">}</span>


        <span class="c">/*p.abx {word-wrap:break-word;}</span>
<span class="c">ought to solve the problem for Safari (the long words will wrap in your</span>
<span class="c">tds, instead of overflowing to the next td.</span>
<span class="c">(this is supported by IE win as well, so hide it if needed).</span>
<span class="c"></span>
<span class="c">One thing, though: it doesn&#39;t work in combination with</span>
<span class="c">&#39;white-space:nowrap&#39;.*/</span>

<span class="c">// need a div wrapper for safari?</span>
<span class="c"></span>        <span class="c">//TODO: fix fixedWidth</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elCell</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">overflow</span> <span class="o">=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">;</span>
            <span class="c">//elCell.style.width = &quot;20px&quot;;</span>
<span class="c"></span>        <span class="o">}</span>
    <span class="o">}</span>

    <span class="k">return</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats all TD elements of given TR element with data from the given Record.</span>
<span class="c"> *</span>
<span class="c"> * @method _updateTrEl</span>
<span class="c"> * @param elRow {HTMLElement} The TR element to update.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} The associated Record instance.</span>
<span class="c"> * @return {String} ID of the updated TR element, or null.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_updateTrEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessage</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">isSortedBy</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;sortedBy&quot;</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">sortedColKeyIndex</span>  <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">sortedDir</span><span class="o">,</span> <span class="nx">newClass</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">isSortedBy</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">sortedColKeyIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">column</span><span class="o">)</span> <span class="o">?</span>
                <span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">()</span> <span class="o">:</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">key</span><span class="o">).</span><span class="nx">getKeyIndex</span><span class="o">();</span>
        <span class="nx">sortedDir</span> <span class="o">=</span> <span class="nx">isSortedBy</span><span class="o">.</span><span class="nx">dir</span><span class="o">;</span>
        <span class="nx">newClass</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortedDir</span> <span class="o">===</span> <span class="s2">&quot;desc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span> <span class="o">:</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Update TD elements with new data</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">formatCell</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">);</span>

        <span class="c">// Remove ASC/DESC</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ASC</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DESC</span><span class="o">);</span>

        <span class="c">// Set ASC/DESC on TD</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">j</span> <span class="o">===</span> <span class="nx">sortedColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">newClass</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Update Record ID</span>
<span class="c"></span>    <span class="nx">elRow</span><span class="o">.</span><span class="nx">yuiRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>
    
    <span class="k">return</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>


<span class="c">/**</span>
<span class="c"> * Deletes TR element by DOM reference or by DataTable page row index.</span>
<span class="c"> *</span>
<span class="c"> * @method _deleteTrEl</span>
<span class="c"> * @param row {HTMLElement | Number} TR element reference or Datatable page row index.</span>
<span class="c"> * @return {Boolean} Returns true if successful, else returns false.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_deleteTrEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">rowIndex</span><span class="o">;</span>
    
    <span class="c">// Get page row index for the element</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">rowIndex</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">row</span><span class="o">).</span><span class="nx">sectionRowIndex</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">rowIndex</span> <span class="o">=</span> <span class="nx">row</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">rowIndex</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">rowIndex</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">2</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">rowIndex</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(</span><span class="nx">rowIndex</span><span class="o">);</span>
        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>



























<span class="c">// CSS/STATE FUNCTIONS</span>
<span class="c"></span>



<span class="c">/**</span>
<span class="c"> * Assigns the class YAHOO.widget.DataTable.CLASS_FIRST to the first TR element</span>
<span class="c"> * of the DataTable page and updates internal tracker.</span>
<span class="c"> *</span>
<span class="c"> * @method _setFirstRow</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_setFirstRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">rowEl</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getFirstTrEl</span><span class="o">();</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">rowEl</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Remove FIRST</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sFirstTrId</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sFirstTrId</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// Set FIRST</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">rowEl</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_sFirstTrId</span> <span class="o">=</span> <span class="nx">rowEl</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_sFirstTrId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Assigns the class YAHOO.widget.DataTable.CLASS_LAST to the last TR element</span>
<span class="c"> * of the DataTable page and updates internal tracker.</span>
<span class="c"> *</span>
<span class="c"> * @method _setLastRow</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_setLastRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">rowEl</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getLastTrEl</span><span class="o">();</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">rowEl</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Unassign previous class</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sLastTrId</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sLastTrId</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// Assign class</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">rowEl</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_sLastTrId</span> <span class="o">=</span> <span class="nx">rowEl</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_sLastTrId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Assigns the classes YAHOO.widget.DataTable.CLASS_EVEN and</span>
<span class="c"> * YAHOO.widget.DataTable.CLASS_ODD to alternating TR elements of the DataTable</span>
<span class="c"> * page. For performance, a subset of rows may be specified.</span>
<span class="c"> *</span>
<span class="c"> * @method _setRowStripes</span>
<span class="c"> * @param row {HTMLElement | String | Number} (optional) HTML TR element reference</span>
<span class="c"> * or string ID, or page row index of where to start striping.</span>
<span class="c"> * @param range {Number} (optional) If given, how many rows to stripe, otherwise</span>
<span class="c"> * stripe all the rows until the end.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_setRowStripes</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">,</span> <span class="nx">range</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Default values stripe all rows</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">nStartIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">nEndIndex</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    
    <span class="c">// Stripe a subset</span>
<span class="c"></span>    <span class="k">if</span><span class="o">((</span><span class="nx">row</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">row</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// Validate given start row</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">elStartRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elStartRow</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">nStartIndex</span> <span class="o">=</span> <span class="nx">elStartRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span>
            
            <span class="c">// Validate given range</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">range</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">range</span> <span class="o">&gt;</span> <span class="m">1</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">nEndIndex</span> <span class="o">=</span> <span class="nx">nStartIndex</span> <span class="o">+</span> <span class="nx">range</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">nStartIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nEndIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">i</span><span class="o">%</span><span class="m">2</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>













































<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private DOM Event Handlers</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Handles scroll events on the CONTAINER (for IE) and TBODY elements (for everyone else).</span>
<span class="c"> *</span>
<span class="c"> * @method _onScroll</span>
<span class="c"> * @param e {HTMLEvent} The scroll event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onScroll</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorBlurEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">cancelCellEditor</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableScrollEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">,</span> <span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles click events on the DOCUMENT.</span>
<span class="c"> *</span>
<span class="c"> * @method _onDocumentClick</span>
<span class="c"> * @param e {HTMLEvent} The click event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onDocumentClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">,</span> <span class="nx">elTarget</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableBlurEvent&quot;</span><span class="o">);</span>

        <span class="c">// Fires editorBlurEvent when click is not within the TABLE.</span>
<span class="c"></span>        <span class="c">// For cases when click is within the TABLE, due to timing issues,</span>
<span class="c"></span>        <span class="c">// the editorBlurEvent needs to get fired by the lower-level DOM click</span>
<span class="c"></span>        <span class="c">// handlers below rather than by the TABLE click handler directly.</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Only if the click was not within the Cell Editor container</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">,</span> <span class="nx">elTarget</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                    <span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">.</span><span class="nx">id</span> <span class="o">!==</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">id</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorBlurEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keydown events on the DOCUMENT.</span>
<span class="c"> *</span>
<span class="c"> * @method _onDocumentKeydown</span>
<span class="c"> * @param e {HTMLEvent} The keydown event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onDocumentKeydown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span> <span class="o">&amp;&amp;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">,</span> <span class="nx">elTarget</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorKeydownEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">,</span> <span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles focus events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableFocus</span>
<span class="c"> * @param e {HTMLEvent} The focus event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableMouseover</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableFocusEvent&quot;</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles mouseover events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableMouseover</span>
<span class="c"> * @param e {HTMLEvent} The mouseover event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableMouseover</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                 <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;span&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">))</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerLabelMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerCellMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;tr&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;thead&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerRowMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">default</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles mouseout events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableMouseout</span>
<span class="c"> * @param e {HTMLEvent} The mouseout event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableMouseout</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;span&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">))</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerLabelMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerCellMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;tr&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;thead&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerRowMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">default</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles mousedown events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableMousedown</span>
<span class="c"> * @param e {HTMLEvent} The mousedown event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableMousedown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;span&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">))</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerLabelMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerCellMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;tr&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;thead&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerRowMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">default</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles dblclick events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableDblclick</span>
<span class="c"> * @param e {HTMLEvent} The dblclick event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableDblclick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellDblclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;span&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">))</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerLabelDblclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerCellDblclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;tr&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;thead&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerRowDblclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowDblclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">default</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableDblclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keydown events on the TABLE element. Handles arrow selection.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableKeydown</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableKeydown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">bSHIFT</span> <span class="o">=</span> <span class="nx">e</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    
    <span class="c">// Ignore actions in the THEAD</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elThead</span><span class="o">,</span> <span class="nx">elTarget</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    
    <span class="k">var</span> <span class="nx">nKey</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    
    <span class="c">// Handle TAB</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">===</span> <span class="m">9</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// From TABLE el focus first TH label link, if any</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(!</span><span class="nx">bSHIFT</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">id</span> <span class="o">===</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_sFirstLabelLinkId</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
            
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_focusEl</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_sFirstLabelLinkId</span><span class="o">));</span>
        <span class="o">}</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Handle ARROW selection</span>
<span class="c"></span>    <span class="k">if</span><span class="o">((</span><span class="nx">nKey</span> <span class="o">&gt;</span> <span class="m">36</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">nKey</span> <span class="o">&lt;</span> <span class="m">41</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        
        <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">sMode</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectionMode&quot;</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">oAnchorCell</span><span class="o">,</span> <span class="nx">oAnchorRecord</span><span class="o">,</span> <span class="nx">nAnchorRecordIndex</span><span class="o">,</span> <span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">oAnchorColumn</span><span class="o">,</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">,</span>
        <span class="nx">oTriggerCell</span><span class="o">,</span> <span class="nx">oTriggerRecord</span><span class="o">,</span> <span class="nx">nTriggerRecordIndex</span><span class="o">,</span> <span class="nx">nTriggerTrIndex</span><span class="o">,</span> <span class="nx">oTriggerColumn</span><span class="o">,</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">,</span> <span class="nx">elTriggerRow</span><span class="o">,</span>
        <span class="nx">startIndex</span><span class="o">,</span> <span class="nx">endIndex</span><span class="o">,</span> <span class="nx">anchorPos</span><span class="o">,</span> <span class="nx">elNext</span><span class="o">;</span>
        
        <span class="c">// Row mode</span>
<span class="c"></span>        <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;standard&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;single&quot;</span><span class="o">))</span> <span class="o">{</span>
            <span class="c">// Validate trigger row:</span>
<span class="c"></span>            <span class="c">// Arrow selection only works if last selected row is on current page</span>
<span class="c"></span>            <span class="nx">oTriggerRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getLastSelectedRecord</span><span class="o">();</span>
            <span class="c">// No selected rows found</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(!</span><span class="nx">oTriggerRecord</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">return</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">oTriggerRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">oTriggerRecord</span><span class="o">);</span>
                <span class="nx">nTriggerRecordIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oTriggerRecord</span><span class="o">);</span>
                <span class="nx">elTriggerRow</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">oTriggerRecord</span><span class="o">);</span>
                <span class="nx">nTriggerTrIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">elTriggerRow</span><span class="o">);</span>
                
                <span class="c">// Last selected row not found on this page</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">return</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
           
            <span class="c">// Validate anchor row</span>
<span class="c"></span>            <span class="nx">oAnchorRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorRecord</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(!</span><span class="nx">oAnchorRecord</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oAnchorRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oTriggerRecord</span><span class="o">;</span>
            <span class="o">}</span>
            
            <span class="nx">nAnchorRecordIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="c">// If anchor row is not on this page...</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// ...set TR index equal to top TR</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getFirstTrEl</span><span class="o">()))</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="c">// ...set TR index equal to bottom TR</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getLastTrEl</span><span class="o">());</span>
                <span class="o">}</span>
            <span class="o">}</span>






        <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>        <span class="c">//</span>
<span class="c"></span>        <span class="c">// SHIFT row selection</span>
<span class="c"></span>        <span class="c">//</span>
<span class="c"></span>        <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">bSHIFT</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;single&quot;</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&gt;</span> <span class="nx">nTriggerTrIndex</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTriggerTrIndex</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">anchorPos</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
            <span class="o">}</span>

            <span class="c">// Arrow down</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Selecting away from anchor row</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&lt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Select the next row down</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">]);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Unselecting toward anchor row</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="c">// Unselect this row towards the anchor row down</span>
<span class="c"></span>                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectRow</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">]);</span>
                <span class="o">}</span>

            <span class="o">}</span>
            <span class="c">// Arrow up</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Selecting away from anchor row</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&gt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Select the next row up</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">]);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Unselect this row towards the anchor row up</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectRow</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">]);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Arrow right</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">39</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Do nothing</span>
<span class="c"></span>            <span class="o">}</span>
            <span class="c">// Arrow left</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">37</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Do nothing</span>
<span class="c"></span>            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>        <span class="c">//</span>
<span class="c"></span>        <span class="c">// Simple single row selection</span>
<span class="c"></span>        <span class="c">//</span>
<span class="c"></span>        <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="c">// Arrow down</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>

                <span class="c">// Select the next row</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                <span class="o">}</span>
                <span class="c">// Select only the last row</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">];</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                <span class="o">}</span>

                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="c">// Arrow up</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>

                <span class="c">// Select the previous row</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                <span class="o">}</span>
                <span class="c">// Select only the first row</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">];</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                <span class="o">}</span>

                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="c">// Arrow right</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">39</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Do nothing</span>
<span class="c"></span>            <span class="o">}</span>
            <span class="c">// Arrow left</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">37</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Do nothing</span>
<span class="c"></span>            <span class="o">}</span>








    <span class="o">}</span>









        <span class="o">}</span>
        <span class="c">// Cell mode</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="c">// Validate trigger cell:</span>
<span class="c"></span>            <span class="c">// Arrow selection only works if last selected cell is on current page</span>
<span class="c"></span>            <span class="nx">oTriggerCell</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getLastSelectedCell</span><span class="o">();</span>
            <span class="c">// No selected cells found</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(!</span><span class="nx">oTriggerCell</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">oTriggerRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">oTriggerCell</span><span class="o">.</span><span class="nx">recordId</span><span class="o">);</span>
                <span class="nx">nTriggerRecordIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oTriggerRecord</span><span class="o">);</span>
                <span class="nx">elTriggerRow</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">oTriggerRecord</span><span class="o">);</span>
                <span class="nx">nTriggerTrIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">elTriggerRow</span><span class="o">);</span>

                <span class="c">// Last selected cell not found on this page</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">return</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">oTriggerColumn</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">oTriggerCell</span><span class="o">.</span><span class="nx">columnId</span><span class="o">);</span>
                    <span class="nx">nTriggerColKeyIndex</span> <span class="o">=</span> <span class="nx">oTriggerColumn</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">();</span>
                <span class="o">}</span>
            <span class="o">}</span>

            <span class="c">// Validate anchor cell</span>
<span class="c"></span>            <span class="nx">oAnchorCell</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(!</span><span class="nx">oAnchorCell</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oAnchorCell</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="nx">oTriggerCell</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="nx">oAnchorRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
            <span class="nx">nAnchorRecordIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="c">// If anchor cell is not on this page...</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// ...set TR index equal to top TR</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getFirstTrEl</span><span class="o">()))</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="c">// ...set TR index equal to bottom TR</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getLastTrEl</span><span class="o">());</span>
                <span class="o">}</span>
            <span class="o">}</span>

            <span class="nx">oAnchorColumn</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
            <span class="nx">nAnchorColKeyIndex</span> <span class="o">=</span> <span class="nx">oAnchorColumn</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">();</span>


            <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>            <span class="c">//</span>
<span class="c"></span>            <span class="c">// SHIFT cell block selection</span>
<span class="c"></span>            <span class="c">//</span>
<span class="c"></span>            <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">bSHIFT</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Arrow DOWN</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Is the anchor cell above, below, or same row as trigger</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&gt;</span> <span class="nx">nTriggerRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTriggerRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                    <span class="o">}</span>

                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&lt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the horiz block on the next row...</span>
<span class="c"></span>                        <span class="c">// ...making sure there is room below the trigger row</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select in order from anchor to trigger...</span>
<span class="c"></span>                            <span class="nx">startIndex</span> <span class="o">=</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">;</span>
                            <span class="nx">endIndex</span> <span class="o">=</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">;</span>
                            <span class="c">// ...going left</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">startIndex</span> <span class="o">&gt;</span> <span class="nx">endIndex</span><span class="o">)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                            <span class="c">// ... going right</span>
<span class="c"></span>                            <span class="k">else</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">);</span>
                        <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">);</span>
                        <span class="c">// Unselect the horiz block on this row towards the next row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Arrow up</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Is the anchor cell above, below, or same row as trigger</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&gt;</span> <span class="nx">nTriggerRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTriggerRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                    <span class="o">}</span>
                    
                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&gt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the horiz block on the previous row...</span>
<span class="c"></span>                        <span class="c">// ...making sure there is room</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select in order from anchor to trigger...</span>
<span class="c"></span>                            <span class="nx">startIndex</span> <span class="o">=</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">;</span>
                            <span class="nx">endIndex</span> <span class="o">=</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">;</span>
                            <span class="c">// ...going left</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">startIndex</span> <span class="o">&gt;</span> <span class="nx">endIndex</span><span class="o">)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                            <span class="c">// ... going right</span>
<span class="c"></span>                            <span class="k">else</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>

                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">);</span>
                        <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">);</span>
                        <span class="c">// Unselect the horiz block on this row towards the previous row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Arrow right</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">39</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Is the anchor cell left, right, or same column</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&gt;</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                    <span class="o">}</span>

                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&lt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the next vert block to the right...</span>
<span class="c"></span>                        <span class="c">// ...making sure there is room</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select in order from anchor to trigger...</span>
<span class="c"></span>                            <span class="nx">startIndex</span> <span class="o">=</span> <span class="nx">nAnchorTrIndex</span><span class="o">;</span>
                            <span class="nx">endIndex</span> <span class="o">=</span> <span class="nx">nTriggerTrIndex</span><span class="o">;</span>
                            <span class="c">// ...going up</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">startIndex</span> <span class="o">&gt;</span> <span class="nx">endIndex</span><span class="o">)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                            <span class="c">// ... going down</span>
<span class="c"></span>                            <span class="k">else</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Unselect the vert block on this column towards the right</span>
<span class="c"></span>                        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">nTriggerTrIndex</span><span class="o">);</span>
                        <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">nTriggerTrIndex</span><span class="o">);</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Arrow left</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">37</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Is the anchor cell left, right, or same column</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&gt;</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                    <span class="o">}</span>

                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&gt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">//Select the previous vert block to the left</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select in order from anchor to trigger...</span>
<span class="c"></span>                            <span class="nx">startIndex</span> <span class="o">=</span> <span class="nx">nAnchorTrIndex</span><span class="o">;</span>
                            <span class="nx">endIndex</span> <span class="o">=</span> <span class="nx">nTriggerTrIndex</span><span class="o">;</span>
                            <span class="c">// ...going up</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">startIndex</span> <span class="o">&gt;</span> <span class="nx">endIndex</span><span class="o">)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                            <span class="c">// ... going down</span>
<span class="c"></span>                            <span class="k">else</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                    <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Unselect the vert block on this column towards the left</span>
<span class="c"></span>                        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">nTriggerTrIndex</span><span class="o">);</span>
                        <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">nTriggerTrIndex</span><span class="o">);</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>            <span class="c">//</span>
<span class="c"></span>            <span class="c">// SHIFT cell range selection</span>
<span class="c"></span>            <span class="c">//</span>
<span class="c"></span>            <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">bSHIFT</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Is the anchor cell above, below, or same row as trigger</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&gt;</span> <span class="nx">nTriggerRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTriggerRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">anchorPos</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">anchorPos</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                <span class="o">}</span>

                <span class="c">// Arrow down</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&lt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select all cells to the end of this row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTriggerColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
                            <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                        <span class="o">}</span>

                        <span class="c">// Select some of the cells on the next row down</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTriggerColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
                                <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Unselect all cells to the end of this row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTriggerColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>

                        <span class="c">// Unselect some of the cells on the next row down</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nTriggerColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Arrow up</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&gt;=</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select all the cells to the beginning of this row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTriggerColKeyIndex</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--){</span>
                            <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                        <span class="o">}</span>

                        <span class="c">// Select some of the cells from the end of the previous row</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">nTriggerColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--){</span>
                                <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Unselect all the cells to the beginning of this row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTriggerColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--){</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>

                        <span class="c">// Unselect some of the cells from the end of the previous row</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;</span><span class="nx">nTriggerColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--){</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Arrow right</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">39</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&lt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the next cell to the right</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                        <span class="o">}</span>
                        <span class="c">// Select the first cell of the next row</span>
<span class="c"></span>                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">]);</span>

                        <span class="c">// Unselect this cell towards the right</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                        <span class="o">}</span>
                        <span class="c">// Unselect this cells towards the first cell of the next row</span>
<span class="c"></span>                        <span class="k">else</span> <span class="o">{</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Anchor is on this row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Selecting away from anchor</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&lt;=</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select the next cell to the right</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                            <span class="o">}</span>
                            <span class="c">// Select the first cell on the next row</span>
<span class="c"></span>                            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">){</span>
                                <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="c">// Unselecting towards anchor</span>
<span class="c"></span>                        <span class="k">else</span> <span class="o">{</span>
                            <span class="c">// Unselect this cell towards the right</span>
<span class="c"></span>                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Arrow left</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">37</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Unselecting towards the anchor</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&lt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">]);</span>

                        <span class="c">// Unselect this cell towards the left</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="o">}</span>
                        <span class="c">// Unselect this cell towards the last cell of the previous row</span>
<span class="c"></span>                        <span class="k">else</span> <span class="o">{</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Selecting towards the anchor</span>
<span class="c"></span>                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">anchorPos</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the next cell to the left</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                        <span class="o">}</span>
                        <span class="c">// Select the last cell of the previous row</span>
<span class="c"></span>                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">){</span>
                            <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Anchor is on this row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Selecting away from anchor cell</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&gt;=</span> <span class="nx">nTriggerColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select the next cell to the left</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                            <span class="o">}</span>
                            <span class="c">// Select the last cell of the previous row</span>
<span class="c"></span>                            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">){</span>
                                <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="c">// Unselecting towards anchor cell</span>
<span class="c"></span>                        <span class="k">else</span> <span class="o">{</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">]);</span>

                            <span class="c">// Unselect this cell towards the left</span>
<span class="c"></span>                            <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                            <span class="o">}</span>
                            <span class="c">// Unselect this cell towards the last cell of the previous row</span>
<span class="c"></span>                            <span class="k">else</span> <span class="o">{</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>            <span class="c">//</span>
<span class="c"></span>            <span class="c">// Simple single cell selection</span>
<span class="c"></span>            <span class="c">//</span>
<span class="c"></span>            <span class="c">////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;singlecell&quot;</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Arrow down</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>

                    <span class="c">// Select the next cell down</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="c">// Select only the bottom cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>

                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elNext</span><span class="o">),</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elNext</span><span class="o">)};</span>
                <span class="o">}</span>
                <span class="c">// Arrow up</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>

                    <span class="c">// Select the next cell up</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerTrIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="c">// Select only the top cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>

                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elNext</span><span class="o">),</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elNext</span><span class="o">)};</span>
                <span class="o">}</span>
                <span class="c">// Arrow right</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">39</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>

                    <span class="c">// Select the next cell to the right</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="c">// Select only the right cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>

                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elNext</span><span class="o">),</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elNext</span><span class="o">)};</span>
                <span class="o">}</span>
                <span class="c">// Arrow left</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">37</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>

                    <span class="c">// Select the next cell to the left</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nTriggerColKeyIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="c">// Select only the left cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">elNext</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTriggerTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">nTriggerColKeyIndex</span><span class="o">];</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elNext</span><span class="o">);</span>
                    <span class="o">}</span>

                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elNext</span><span class="o">),</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elNext</span><span class="o">)};</span>
                <span class="o">}</span>
            <span class="o">}</span>













        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="c">//TODO: handle tab across cells</span>
<span class="c"></span>        <span class="c">//TODO: handle backspace</span>
<span class="c"></span>        <span class="c">//TODO: handle delete</span>
<span class="c"></span>        <span class="c">//TODO: handle arrow selection across pages</span>
<span class="c"></span>        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keypress events on the TABLE. Mainly to support stopEvent on Mac.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTableKeypress</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTableKeypress</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">isMac</span> <span class="o">=</span> <span class="o">(</span><span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">().</span><span class="nx">indexOf</span><span class="o">(</span><span class="s2">&quot;mac&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">isMac</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">nKey</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="c">// arrow down</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// arrow up</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nKey</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles click events on the THEAD element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTheadClick</span>
<span class="c"> * @param e {HTMLEvent} The click event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTheadClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorBlurEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
    <span class="o">}</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;thead&quot;</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;span&quot;</span><span class="o">:</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LABEL</span><span class="o">))</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerLabelClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="o">}</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerCellClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;tr&quot;</span><span class="o">:</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headerRowClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">default</span><span class="o">:</span>
                    <span class="k">break</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
            <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles click events on the primary TBODY element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTbodyClick</span>
<span class="c"> * @param e {HTMLEvent} The click event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onTbodyClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorBlurEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
    <span class="o">}</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;input&quot;</span><span class="o">:</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;checkboxClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;radioClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="o">}</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;linkClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;button&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;buttonClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;tr&quot;</span><span class="o">:</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">default</span><span class="o">:</span>
                <span class="k">break</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:(</span><span class="nx">elTarget</span> <span class="o">||</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">),</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/*TODO: delete</span>
<span class="c"> * Handles keyup events on the TBODY. Executes deletion.</span>
<span class="c"> *</span>
<span class="c"> * @method _onTbodyKeyup</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="c">/*YAHOO.widget.DataTable.prototype._onTbodyKeyup = function(e, oSelf) {</span>
<span class="c">   var nKey = YAHOO.util.Event.getCharCode(e);</span>
<span class="c">    // delete</span>
<span class="c">    if(nKey == 46) {//TODO: if something is selected</span>
<span class="c">        //TODO: delete row</span>
<span class="c">    }</span>
<span class="c">};*/</span>

<span class="c">/**</span>
<span class="c"> * Handles click events on paginator links.</span>
<span class="c"> *</span>
<span class="c"> * @method _onPaginatorLinkClick</span>
<span class="c"> * @param e {HTMLEvent} The click event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onPaginatorLinkClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorBlurEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
    <span class="o">}</span>

    <span class="k">while</span><span class="o">(</span><span class="nx">elTarget</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="nx">case</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                <span class="c">//TODO: after the showPage call, figure out which link</span>
<span class="c"></span>                <span class="c">//TODO: was clicked and reset focus to the new version of it</span>
<span class="c"></span>                <span class="nx">switch</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">className</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGE</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nb">parseInt</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">innerHTML</span><span class="o">,</span><span class="m">10</span><span class="o">));</span>
                        <span class="k">return</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="m">1</span><span class="o">);</span>
                        <span class="k">return</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">totalPages</span><span class="o">);</span>
                        <span class="k">return</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVIOUS</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">currentPage</span> <span class="o">-</span> <span class="m">1</span><span class="o">);</span>
                        <span class="k">return</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXT</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">currentPage</span> <span class="o">+</span> <span class="m">1</span><span class="o">);</span>
                        <span class="k">return</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="nx">default</span><span class="o">:</span>
                <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles change events on paginator SELECT element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onPaginatorDropdownChange</span>
<span class="c"> * @param e {HTMLEvent} The change event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onPaginatorDropdownChange</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">newValue</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">[</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">selectedIndex</span><span class="o">].</span><span class="nx">value</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">newRowsPerPage</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nb">parseInt</span><span class="o">(</span><span class="nx">newValue</span><span class="o">,</span><span class="m">10</span><span class="o">))</span> <span class="o">?</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">newValue</span><span class="o">,</span><span class="m">10</span><span class="o">)</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">newRowsPerPage</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">newStartRecordIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">currentPage</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">*</span> <span class="nx">newRowsPerPage</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">({</span><span class="nx">rowsPerPage</span><span class="o">:</span><span class="nx">newRowsPerPage</span><span class="o">,</span> <span class="nx">startRecordIndex</span><span class="o">:</span><span class="nx">newStartRecordIndex</span><span class="o">});</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">refreshView</span><span class="o">();</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not paginate with &quot;</span> <span class="o">+</span> <span class="nx">newValue</span> <span class="o">+</span> <span class="s2">&quot; rows per page&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles change events on SELECT elements within DataTable.</span>
<span class="c"> *</span>
<span class="c"> * @method _onDropdownChange</span>
<span class="c"> * @param e {HTMLEvent} The change event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onDropdownChange</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="c">//TODO: pass what args?</span>
<span class="c"></span>    <span class="c">//var value = elTarget[elTarget.selectedIndex].value;</span>
<span class="c"></span>    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dropdownChangeEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">,</span> <span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">});</span>
<span class="o">};</span>







































<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public member variables</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public methods</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">// OBJECT ACCESSORS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Public accessor to the unique name of the DataSource instance.</span>
<span class="c"> *</span>
<span class="c"> * @method toString</span>
<span class="c"> * @return {String} Unique name of the DataSource instance.</span>
<span class="c"> */</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">toString</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="s2">&quot;DataTable &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sName</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns the DataTable instance&#39;s DataSource instance.</span>
<span class="c"> *</span>
<span class="c"> * @method getDataSource</span>
<span class="c"> * @return {YAHOO.util.DataSource} DataSource instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getDataSource</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oDataSource</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns the DataTable instance&#39;s ColumnSet instance.</span>
<span class="c"> *</span>
<span class="c"> * @method getColumnSet</span>
<span class="c"> * @return {YAHOO.widget.ColumnSet} ColumnSet instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getColumnSet</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns the DataTable instance&#39;s RecordSet instance.</span>
<span class="c"> *</span>
<span class="c"> * @method getRecordSet</span>
<span class="c"> * @return {YAHOO.widget.RecordSet} RecordSet instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getRecordSet</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns the DataTable instance&#39;s Cell Editor as an object literal with the</span>
<span class="c"> * following properties:</span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;cell&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;{HTMLElement} Cell element being edited.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;dt&gt;column&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;{YAHOO.widget.Column} Associated Column instance.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;dt&gt;container&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;{HTMLElement} Reference to editor&#39;s container DIV element.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;dt&gt;isActive&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;{Boolean} True if cell is currently being edited.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;dt&gt;record&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;{YAHOO.widget.Record} Associated Record instance.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;dt&gt;validator&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;{HTMLFunction} Associated validator function called before new data is stored. Called</span>
<span class="c"> * within the scope of the DataTable instance, the function receieves the</span>
<span class="c"> * following arguments:</span>
<span class="c"> *</span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> *  &lt;dt&gt;oNewData&lt;/dt&gt;</span>
<span class="c"> *  &lt;dd&gt;{Object} New data to validate.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> *  &lt;dt&gt;oOldData&lt;/dt&gt;</span>
<span class="c"> *  &lt;dd&gt;{Object} Original data in case of reversion.&lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> *  &lt;dt&gt;oCellEditor&lt;/dt&gt;</span>
<span class="c"> *  &lt;dd&gt;{Object} Object literal representation of Editor values.&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> *</span>
<span class="c"> *  &lt;/dd&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;dt&gt;value&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Current input value&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> * @method getCellEditor</span>
<span class="c"> * @return {Object} Cell Editor object literal values.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">;</span>
<span class="o">};</span>











































<span class="c">// DOM ACCESSORS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the DataTable&#39;s TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method getTableEl</span>
<span class="c"> * @return {HTMLElement} Reference to TABLE element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTableEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the DataTable&#39;s THEAD element.</span>
<span class="c"> *</span>
<span class="c"> * @method getTheadEl</span>
<span class="c"> * @return {HTMLElement} Reference to THEAD element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTheadEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the DataTable&#39;s primary TBODY element.</span>
<span class="c"> *</span>
<span class="c"> * @method getTbodyEl</span>
<span class="c"> * @return {HTMLElement} Reference to TBODY element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTbodyEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">// Backward compatibility</span>
<span class="c"></span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getBody</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;The method getBody() has been deprecated&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; in favor of getTbodyEl()&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTbodyEl</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the DataTable&#39;s secondary TBODY element that is</span>
<span class="c"> * used to display messages.</span>
<span class="c"> *</span>
<span class="c"> * @method getMsgTbodyEl</span>
<span class="c"> * @return {HTMLElement} Reference to TBODY element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getMsgTbodyEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTbody</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the TD element within the secondary TBODY that is</span>
<span class="c"> * used to display messages.</span>
<span class="c"> *</span>
<span class="c"> * @method getMsgTdEl</span>
<span class="c"> * @return {HTMLElement} Reference to TD element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getMsgTdEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTd</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns the corresponding TR reference for a given DOM element, ID string or</span>
<span class="c"> * directly page row index. If the given identifier is a child of a TR element,</span>
<span class="c"> * then DOM tree is traversed until a parent TR element is returned, otherwise</span>
<span class="c"> * null.</span>
<span class="c"> *</span>
<span class="c"> * @method getTrEl</span>
<span class="c"> * @param row {HTMLElement | String | Number | YAHOO.widget.Record} Which row to</span>
<span class="c"> * get: by element reference, ID string, page row index, or Record.</span>
<span class="c"> * @return {HTMLElement} Reference to TR element, or null.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTrEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
    
    <span class="c">// By Record</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">row</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">nTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">nTrIndex</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">nTrIndex</span><span class="o">];</span>
            <span class="o">}</span>
            <span class="c">// Not a valid Record</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
            <span class="o">}</span>
    <span class="o">}</span>
    <span class="c">// By page row index</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">row</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">row</span> <span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">row</span><span class="o">];</span>
    <span class="o">}</span>
    <span class="c">// By ID string or element reference</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elRow</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        
        <span class="c">// Validate HTML element</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">==</span> <span class="nb">document</span><span class="o">))</span> <span class="o">{</span>
            <span class="c">// Validate TR element</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;tr&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Traverse up the DOM to find the corresponding TR element</span>
<span class="c"></span>                <span class="nx">elRow</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getAncestorByTagName</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">elRow</span> <span class="o">=</span> <span class="nx">el</span><span class="o">;</span>
            <span class="o">}</span>

            <span class="c">// Make sure the TR is in this TBODY</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Now we can return the TR element</span>
<span class="c"></span>                <span class="k">return</span> <span class="nx">elRow</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get TR element for row &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">// Backward compatibility</span>
<span class="c"></span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;The method getRow() has been deprecated&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; in favor of getTrEl()&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">index</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the first TR element in the DataTable page, or null.</span>
<span class="c"> *</span>
<span class="c"> * @method getFirstTrEl</span>
<span class="c"> * @return {HTMLElement} Reference to TR element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getFirstTrEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">||</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to the last TR element in the DataTable page, or null.</span>
<span class="c"> *</span>
<span class="c"> * @method getLastTrEl</span>
<span class="c"> * @return {HTMLElement} Reference to last TR element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getLastTrEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">]</span> <span class="o">||</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to a TD element.</span>
<span class="c"> *</span>
<span class="c"> * @method getTdEl</span>
<span class="c"> * @param cell {HTMLElement | String | Object} DOM element reference or string ID, or</span>
<span class="c"> * object literal of syntax {record:oRecord, column:oColumn}.</span>
<span class="c"> * @return {HTMLElement} Reference to TD element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTdEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">cell</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">cell</span><span class="o">);</span>

    <span class="c">// Validate HTML element</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">==</span> <span class="nb">document</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// Validate TD element</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Traverse up the DOM to find the corresponding TR element</span>
<span class="c"></span>            <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getAncestorByTagName</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s2">&quot;td&quot;</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">el</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Make sure the TD is in this TBODY</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">))</span> <span class="o">{</span>
            <span class="c">// Now we can return the TD element</span>
<span class="c"></span>            <span class="k">return</span> <span class="nx">elCell</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">cell</span><span class="o">.</span><span class="nx">record</span> <span class="o">&amp;&amp;</span> <span class="nx">cell</span><span class="o">.</span><span class="nx">column</span> <span class="o">&amp;&amp;</span> <span class="nx">cell</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">cell</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span> <span class="o">&amp;&amp;</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span> <span class="o">&amp;&amp;</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">cell</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">()]</span> <span class="o">||</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get TD element for cell &quot;</span> <span class="o">+</span> <span class="nx">cell</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns DOM reference to a TH element.</span>
<span class="c"> *</span>
<span class="c"> * @method getThEl</span>
<span class="c"> * @param header {YAHOO.widget.Column | HTMLElement | String} Column instance,</span>
<span class="c"> * DOM element reference, or string ID.</span>
<span class="c"> * @return {HTMLElement} Reference to TH element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getThEl</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">header</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elHeader</span><span class="o">;</span>
        
    <span class="c">// Validate Column instance</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">header</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Column</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">header</span><span class="o">;</span>
        <span class="nx">elHeader</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">());</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elHeader</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">elHeader</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="c">// Validate HTML element</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">header</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">==</span> <span class="nb">document</span><span class="o">))</span> <span class="o">{</span>
            <span class="c">// Validate TH element</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;th&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Traverse up the DOM to find the corresponding TR element</span>
<span class="c"></span>                <span class="nx">elHeader</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getAncestorByTagName</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span><span class="s2">&quot;th&quot;</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">elHeader</span> <span class="o">=</span> <span class="nx">el</span><span class="o">;</span>
            <span class="o">}</span>

            <span class="c">// Make sure the TH is in this THEAD</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">elHeader</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elHeader</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Now we can return the TD element</span>
<span class="c"></span>                <span class="k">return</span> <span class="nx">elHeader</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get TH element for header &quot;</span> <span class="o">+</span> <span class="nx">header</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns the page row index of given row. Returns null if the row is not on the</span>
<span class="c"> * current DataTable page.</span>
<span class="c"> *</span>
<span class="c"> * @method getTrIndex</span>
<span class="c"> * @param row {HTMLElement | String | YAHOO.widget.Record | Number} DOM or ID</span>
<span class="c"> * string reference to an element within the DataTable page, a Record instance,</span>
<span class="c"> * or a Record&#39;s RecordSet index.</span>
<span class="c"> * @return {Number} Page row index, or null if row does not exist or is not on current page.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTrIndex</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">nRecordIndex</span><span class="o">;</span>
    
    <span class="c">// By Record</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">row</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">nRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">nRecordIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Not a valid Record</span>
<span class="c"></span>            <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="c">// Calculate page row index from Record index</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">nRecordIndex</span> <span class="o">=</span> <span class="nx">row</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nRecordIndex</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// Validate the number</span>
<span class="c"></span>        <span class="k">if</span><span class="o">((</span><span class="nx">nRecordIndex</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">nRecordIndex</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getLength</span><span class="o">()))</span> <span class="o">{</span>
            <span class="c">// DataTable is paginated</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginated&quot;</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Get the first and last Record on current page</span>
<span class="c"></span>                <span class="k">var</span> <span class="nx">startRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">startRecordIndex</span><span class="o">;</span>
                <span class="k">var</span> <span class="nx">endRecordIndex</span> <span class="o">=</span> <span class="nx">startRecordIndex</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">rowsPerPage</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
                <span class="c">// This Record is on current page</span>
<span class="c"></span>                <span class="k">if</span><span class="o">((</span><span class="nx">nRecordIndex</span> <span class="o">&gt;=</span> <span class="nx">startRecordIndex</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">nRecordIndex</span> <span class="o">&lt;=</span> <span class="nx">endRecordIndex</span><span class="o">))</span> <span class="o">{</span>
                    <span class="k">return</span> <span class="nx">nRecordIndex</span> <span class="o">-</span> <span class="nx">startRecordIndex</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="c">// This Record is not on current page</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Not paginated, just return the Record index</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">nRecordIndex</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// RecordSet index is out of range</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="c">// By element reference or ID string</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="c">// Validate TR element</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">==</span> <span class="nb">document</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                <span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get page row index for row &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>














































<span class="c">// TABLE FUNCTIONS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Resets a RecordSet with the given data and populates the page view</span>
<span class="c"> * with the new data. Any previous data and selection states are cleared.</span>
<span class="c"> * However, sort states are not cleared, so if the given data is in a particular</span>
<span class="c"> * sort order, implementers should take care to reset the sortedBy property. If</span>
<span class="c"> * pagination is enabled, the currentPage is shown and Paginator UI updated,</span>
<span class="c"> * otherwise all rows are displayed as a single page. For performance, existing</span>
<span class="c"> * DOM elements are reused when possible.</span>
<span class="c"> *</span>
<span class="c"> * @method initializeTable</span>
<span class="c"> * @param oData {Object | Object[]} An object literal of data or an array of</span>
<span class="c"> * object literals containing data.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">initializeTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Clear the RecordSet</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">reset</span><span class="o">();</span>

    <span class="c">// Add data to RecordSet</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">records</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">addRecords</span><span class="o">(</span><span class="nx">oData</span><span class="o">);</span>

    <span class="c">// Clear selections</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllTrEls</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllTdEls</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

    <span class="c">// Refresh the view</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">refreshView</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;initEvent&quot;</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Refreshes the view with existing Records from the RecordSet while</span>
<span class="c"> * maintaining sort, pagination, and selection states. For performance, reuses</span>
<span class="c"> * existing DOM elements when possible while deleting extraneous elements.</span>
<span class="c"> *</span>
<span class="c"> * @method refreshView</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">refreshView</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">k</span><span class="o">,</span> <span class="nx">l</span><span class="o">,</span> <span class="nx">aRecords</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oPaginator</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">();</span>

    <span class="c">// Paginator is enabled, show a subset of Records and update Paginator UI</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginated&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">rowsPerPage</span> <span class="o">=</span> <span class="nx">oPaginator</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">startRecordIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oPaginator</span><span class="o">.</span><span class="nx">currentPage</span> <span class="o">-</span> <span class="m">1</span><span class="o">)</span> <span class="o">*</span> <span class="nx">rowsPerPage</span><span class="o">;</span>
        <span class="nx">aRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecords</span><span class="o">(</span><span class="nx">startRecordIndex</span><span class="o">,</span> <span class="nx">rowsPerPage</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">formatPaginators</span><span class="o">();</span>
    <span class="o">}</span>
    <span class="c">// Show all records</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">aRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecords</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="k">var</span> <span class="nx">elTbody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elRows</span> <span class="o">=</span> <span class="nx">elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>

    <span class="c">// Has rows</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessage</span><span class="o">();</span>

        <span class="c">// Keep track of selected rows</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">aSelectedRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getSelectedRows</span><span class="o">();</span>
        <span class="c">// Keep track of selected cells</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">aSelectedCells</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getSelectedCells</span><span class="o">();</span>
        <span class="c">// Anything to reinstate?</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">bReselect</span> <span class="o">=</span> <span class="o">(</span><span class="nx">aSelectedRows</span><span class="o">.</span><span class="nx">length</span><span class="o">&gt;</span><span class="m">0</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">aSelectedCells</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">);</span>

        <span class="c">// Remove extra rows from the bottom so as to preserve ID order</span>
<span class="c"></span>        <span class="k">while</span><span class="o">(</span><span class="nx">elTbody</span><span class="o">.</span><span class="nx">hasChildNodes</span><span class="o">()</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">elTbody</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(-</span><span class="m">1</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Unselect all TR and TD elements in the UI</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">bReselect</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllTrEls</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllTdEls</span><span class="o">();</span>
        <span class="o">}</span>

        <span class="c">// From the top, update in-place existing rows</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_updateTrEl</span><span class="o">(</span><span class="nx">elRows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
        <span class="o">}</span>

        <span class="c">// Add TR elements as necessary</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_addTrEl</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
        <span class="o">}</span>

        <span class="c">// Reinstate selected and sorted classes</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">bReselect</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Loop over each row</span>
<span class="c"></span>            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">thisRow</span> <span class="o">=</span> <span class="nx">elRows</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
                <span class="k">var</span> <span class="nx">sMode</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectionMode&quot;</span><span class="o">);</span>
                <span class="k">if</span> <span class="o">((</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;standard&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;single&quot;</span><span class="o">))</span> <span class="o">{</span>
                    <span class="c">// Set SELECTED</span>
<span class="c"></span>                    <span class="k">for</span><span class="o">(</span><span class="nx">k</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">k</span><span class="o">&lt;</span><span class="nx">aSelectedRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">k</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="k">if</span><span class="o">(</span><span class="nx">aSelectedRows</span><span class="o">[</span><span class="nx">k</span><span class="o">]</span> <span class="o">===</span> <span class="nx">thisRow</span><span class="o">.</span><span class="nx">yuiRecordId</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">thisRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
                            <span class="k">if</span><span class="o">(</span><span class="nx">j</span> <span class="o">===</span> <span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">thisRow</span><span class="o">.</span><span class="nx">yuiRecordId</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="c">// Loop over each cell</span>
<span class="c"></span>                    <span class="k">for</span><span class="o">(</span><span class="nx">k</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">k</span><span class="o">&lt;</span><span class="nx">thisRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">k</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="k">var</span> <span class="nx">thisCell</span> <span class="o">=</span> <span class="nx">thisRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">k</span><span class="o">];</span>
                        <span class="c">// Set SELECTED</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">l</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">l</span><span class="o">&lt;</span><span class="nx">aSelectedCells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">l</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">((</span><span class="nx">aSelectedCells</span><span class="o">[</span><span class="nx">l</span><span class="o">].</span><span class="nx">recordId</span> <span class="o">===</span> <span class="nx">thisRow</span><span class="o">.</span><span class="nx">yuiRecordId</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                                    <span class="o">(</span><span class="nx">aSelectedCells</span><span class="o">[</span><span class="nx">l</span><span class="o">].</span><span class="nx">columnId</span> <span class="o">===</span> <span class="nx">thisCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">))</span> <span class="o">{</span>
                                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">thisCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
                                <span class="k">if</span><span class="o">(</span><span class="nx">k</span> <span class="o">===</span> <span class="nx">thisRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">thisRow</span><span class="o">.</span><span class="nx">yuiRecordId</span><span class="o">),</span> <span class="nx">column</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">thisCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">)};</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        
        <span class="c">// Set FIRST/LAST, EVEN/ODD</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_setFirstRow</span><span class="o">();</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_setLastRow</span><span class="o">();</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_setRowStripes</span><span class="o">();</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;refreshEvent&quot;</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable showing &quot;</span> <span class="o">+</span> <span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; of &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getLength</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="c">// Empty</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="c">// Remove all rows</span>
<span class="c"></span>        <span class="k">while</span><span class="o">(</span><span class="nx">elTbody</span><span class="o">.</span><span class="nx">hasChildNodes</span><span class="o">())</span> <span class="o">{</span>
            <span class="nx">elTbody</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(-</span><span class="m">1</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Nulls out the entire DataTable instance and related objects, removes attached</span>
<span class="c"> * event listeners, and clears out DOM elements inside the container. After</span>
<span class="c"> * calling this method, the instance reference should be expliclitly nulled by</span>
<span class="c"> * implementer, as in myDataTable = null. Use with caution!</span>
<span class="c"> *</span>
<span class="c"> * @method destroy</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">destroy</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">// Destroy Cell Editor</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">);</span>
    
    <span class="k">var</span> <span class="nx">instanceName</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">();</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">;</span>

    <span class="c">// Unhook custom events</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>

    <span class="c">// Unhook DOM events</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

    <span class="c">// Remove DOM elements</span>
<span class="c"></span>    <span class="nx">elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

    <span class="c">// Null out objects</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">param</span> <span class="k">in</span> <span class="k">this</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">param</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">[</span><span class="nx">param</span><span class="o">]</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable instance destroyed: &quot;</span> <span class="o">+</span> <span class="nx">instanceName</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Displays message within secondary TBODY.</span>
<span class="c"> *</span>
<span class="c"> * @method showTableMessage</span>
<span class="c"> * @param sHTML {String} (optional) Value for innerHTML.</span>
<span class="c"> * @param sClassName {String} (optional) Classname.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showTableMessage</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sHTML</span><span class="o">,</span> <span class="nx">sClassName</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTd</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">sHTML</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">sHTML</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">sClassName</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">sClassName</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTbody</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMsgShowEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">html</span><span class="o">:</span><span class="nx">sHTML</span><span class="o">,</span> <span class="nx">className</span><span class="o">:</span><span class="nx">sClassName</span><span class="o">});</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable showing message: &quot;</span> <span class="o">+</span> <span class="nx">sHTML</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Hides secondary TBODY.</span>
<span class="c"> *</span>
<span class="c"> * @method hideTableMessage</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">hideTableMessage</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTbody</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">!=</span> <span class="s2">&quot;none&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgTbody</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMsgHideEvent&quot;</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable message hidden&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Brings focus to DataTable instance.</span>
<span class="c"> *</span>
<span class="c"> * @method focus</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focus</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_focusEl</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">);</span>
<span class="o">};</span>


































































<span class="c">// RECORDSET FUNCTIONS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Returns Record index for given TR element or page row index.</span>
<span class="c"> *</span>
<span class="c"> * @method getRecordIndex</span>
<span class="c"> * @param row {YAHOO.widget.Record | HTMLElement | Number} Record instance, TR</span>
<span class="c"> * element reference or page row index.</span>
<span class="c"> * @return {Number} Record&#39;s RecordSet index, or null.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getRecordIndex</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">nTrIndex</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// By Record</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">row</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// By element reference</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="c">// Find the TR element</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">nTrIndex</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="c">// By page row index</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">nTrIndex</span> <span class="o">=</span> <span class="nx">row</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginated&quot;</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">startRecordIndex</span> <span class="o">+</span> <span class="nx">nTrIndex</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">nTrIndex</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get Record index for row &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * For the given identifier, returns the associated Record instance.</span>
<span class="c"> *</span>
<span class="c"> * @method getRecord</span>
<span class="c"> * @param row {HTMLElement | Number | String} DOM reference to a TR element (or</span>
<span class="c"> * child of a TR element), RecordSet position index, or Record ID.</span>
<span class="c"> * @return {YAHOO.widget.Record} Record instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getRecord</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
    
    <span class="k">if</span><span class="o">(!</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Validate TR element</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">yuiRecordId</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get Record for row at &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>














































<span class="c">// COLUMN FUNCTIONS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * For the given identifier, returns the associated Column instance. Note: For</span>
<span class="c"> * getting Columns by Column ID string, please use the method getColumnById().</span>
<span class="c"> *</span>
<span class="c"> * @method getColumn</span>
<span class="c"> * @param column {HTMLElement | String | Number} DOM reference or ID string to a</span>
<span class="c"> * TH/TD element (or child of a TH/TD element), a Column key, or a ColumnSet key index.</span>
<span class="c"> * @return {YAHOO.widget.Column} Column instance.</span>
<span class="c"> */</span>
 <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getColumn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">column</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">column</span><span class="o">);</span>
    
    <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Validate TD element</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">column</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// Validate TH element</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getThEl</span><span class="o">(</span><span class="nx">column</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not get Column for column at &quot;</span> <span class="o">+</span> <span class="nx">column</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="k">return</span> <span class="nx">oColumn</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * For the given Column ID, returns the associated Column instance. Note: For</span>
<span class="c"> * getting Columns by key, please use the method getColumn().</span>
<span class="c"> *</span>
<span class="c"> * @method getColumnById</span>
<span class="c"> * @param column {String} Column ID string.</span>
<span class="c"> * @return {YAHOO.widget.Column} Column instance.</span>
<span class="c"> */</span>
 <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getColumnById</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">column</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">column</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sorts given Column.</span>
<span class="c"> *</span>
<span class="c"> * @method sortColumn</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">sortColumn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oColumn</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Column</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortable</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">getThEl</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">),</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTABLE</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// What is the default sort direction?</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sortDir</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">defaultOrder</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">defaultOrder</span> <span class="o">:</span> <span class="s2">&quot;asc&quot;</span><span class="o">;</span>

        <span class="c">// Already sorted?</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">oSortedBy</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;sortedBy&quot;</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oSortedBy</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oSortedBy</span><span class="o">.</span><span class="nx">key</span> <span class="o">===</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">oSortedBy</span><span class="o">.</span><span class="nx">dir</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sortDir</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oSortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">==</span> <span class="s2">&quot;asc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="s2">&quot;desc&quot;</span> <span class="o">:</span> <span class="s2">&quot;asc&quot;</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">sortDir</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;asc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="s2">&quot;desc&quot;</span> <span class="o">:</span> <span class="s2">&quot;asc&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Is there a custom sort handler function defined?</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sortFnc</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isFunction</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">sortFunction</span><span class="o">))</span> <span class="o">?</span>
                <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">sortFunction</span> <span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">a</span><span class="o">,</span> <span class="nx">b</span><span class="o">,</span> <span class="nx">desc</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">var</span> <span class="nx">sorted</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Sort</span><span class="o">.</span><span class="nx">compare</span><span class="o">(</span><span class="nx">a</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">),</span><span class="nx">b</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">),</span> <span class="nx">desc</span><span class="o">);</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">sorted</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Sort</span><span class="o">.</span><span class="nx">compare</span><span class="o">(</span><span class="nx">a</span><span class="o">.</span><span class="nx">getId</span><span class="o">(),</span><span class="nx">b</span><span class="o">.</span><span class="nx">getId</span><span class="o">(),</span> <span class="nx">desc</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="nx">sorted</span><span class="o">;</span>
                    <span class="o">}</span>
        <span class="o">};</span>

        <span class="c">// Do the actual sort</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">desc</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;desc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">sortRecords</span><span class="o">(</span><span class="nx">sortFnc</span><span class="o">,</span> <span class="nx">desc</span><span class="o">);</span>

        <span class="c">// Update sortedBy tracker</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;sortedBy&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">key</span><span class="o">:</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> <span class="nx">dir</span><span class="o">:</span><span class="nx">sortDir</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oColumn</span><span class="o">});</span>

        <span class="c">// Reset to first page</span>
<span class="c"></span>        <span class="c">//TODO: Keep selection in view</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">({</span><span class="nx">currentPage</span><span class="o">:</span><span class="m">1</span><span class="o">});</span>

        <span class="c">// Update the UI</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">refreshView</span><span class="o">();</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;columnSortEvent&quot;</span><span class="o">,{</span><span class="nx">column</span><span class="o">:</span><span class="nx">oColumn</span><span class="o">,</span><span class="nx">dir</span><span class="o">:</span><span class="nx">sortDir</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Column \&quot;&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span> <span class="o">+</span> <span class="s2">&quot;\&quot; sorted \&quot;&quot;</span> <span class="o">+</span> <span class="nx">sortDir</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not sort Column \&quot;&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>













































<span class="c">// ROW FUNCTIONS</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c"> * Adds one new Record of data into the RecordSet at the index if given,</span>
<span class="c"> * otherwise at the end. If the new Record is in page view, the</span>
<span class="c"> * corresponding DOM elements are also updated.</span>
<span class="c"> *</span>
<span class="c"> * @method addRow</span>
<span class="c"> * @param oData {Object} Object literal of data for the row.</span>
<span class="c"> * @param index {Number} (optional) RecordSet position index at which to add data.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">addRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oData</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oData</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oData</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">addRecord</span><span class="o">(</span><span class="nx">oData</span><span class="o">,</span> <span class="nx">index</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">nTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>

            <span class="c">// Row is on current page</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// Paginated so just refresh the view to keep pagination state</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginated&quot;</span><span class="o">))</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">refreshView</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="c">// Add the TR element</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">var</span> <span class="nx">newTrId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_addTrEl</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">nTrIndex</span><span class="o">);</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">newTrId</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Is this an insert or an append?</span>
<span class="c"></span>                        <span class="k">var</span> <span class="nx">append</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                                <span class="o">(</span><span class="nx">nTrIndex</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>

                        <span class="c">// Stripe the one new row</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">append</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">((</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">)%</span><span class="m">2</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">newTrId</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span><span class="o">);</span>
                            <span class="o">}</span>
                            <span class="k">else</span> <span class="o">{</span>
                                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">newTrId</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="c">// Restripe all the rows after the new one</span>
<span class="c"></span>                        <span class="k">else</span> <span class="o">{</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">_setRowStripes</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">);</span>
                        <span class="o">}</span>

                        <span class="c">// If new row is at the bottom</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">append</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">_setLastRow</span><span class="o">();</span>
                        <span class="o">}</span>
                        <span class="c">// If new row is at the top</span>
<span class="c"></span>                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">nTrIndex</span> <span class="o">===</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">_setFirstRow</span><span class="o">();</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Record is not on current page so just update pagination UI</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">();</span>
            <span class="o">}</span>

            <span class="c">// TODO: what args to pass?</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowAddEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">});</span>

            <span class="c">// For log message</span>
<span class="c"></span>            <span class="nx">nTrIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">))?</span> <span class="nx">nTrIndex</span> <span class="o">:</span> <span class="s2">&quot;n/a&quot;</span><span class="o">;</span>

            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Added row: Record ID = &quot;</span> <span class="o">+</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">()</span> <span class="o">+</span>
                    <span class="s2">&quot;, Record index = &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">+</span>
                    <span class="s2">&quot;, page row index = &quot;</span> <span class="o">+</span> <span class="nx">nTrIndex</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not add row with &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">dump</span><span class="o">(</span><span class="nx">oData</span><span class="o">),</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Convenience method to add multiple rows.</span>
<span class="c"> *</span>
<span class="c"> * @method addRows</span>
<span class="c"> * @param aData {Object[]} Array of object literal data for the rows.</span>
<span class="c"> * @param index {Number} (optional) RecordSet position index at which to add data.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">addRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">aData</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">aData</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">index</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">aData</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">addRow</span><span class="o">(</span><span class="nx">aData</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">index</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aData</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">addRow</span><span class="o">(</span><span class="nx">aData</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not add rows &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">dump</span><span class="o">(</span><span class="nx">aData</span><span class="o">));</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * For the given row, updates the associated Record with the given data. If the</span>
<span class="c"> * row is on current page, the corresponding DOM elements are also updated.</span>
<span class="c"> *</span>
<span class="c"> * @method updateRow</span>
<span class="c"> * @param row {YAHOO.widget.Record | Number | HTMLElement | String}</span>
<span class="c"> * Which row to update: By Record instance, by Record&#39;s RecordSet</span>
<span class="c"> * position index, by HTMLElement reference to the TR element, or by ID string</span>
<span class="c"> * of the TR element.</span>
<span class="c"> * @param oData {Object} Object literal of data for the row.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">updateRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oldRecord</span><span class="o">,</span> <span class="nx">oldData</span><span class="o">,</span> <span class="nx">updatedRecord</span><span class="o">,</span> <span class="nx">elRow</span><span class="o">;</span>

    <span class="c">// Get the Record directly</span>
<span class="c"></span>    <span class="k">if</span><span class="o">((</span><span class="nx">row</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">)))</span> <span class="o">{</span>
            <span class="c">// Get the Record directly</span>
<span class="c"></span>            <span class="nx">oldRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
            
            <span class="c">// Is this row on current page?</span>
<span class="c"></span>            <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">oldRecord</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Get the Record by TR element</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oldRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Update the Record</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">oldRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Copy data from the Record for the event that gets fired later</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">oRecordData</span> <span class="o">=</span> <span class="nx">oldRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">();</span>
        <span class="nx">oldData</span> <span class="o">=</span> <span class="o">{};</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">param</span> <span class="k">in</span> <span class="nx">oRecordData</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oldData</span><span class="o">[</span><span class="nx">param</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oRecordData</span><span class="o">[</span><span class="nx">param</span><span class="o">];</span>
        <span class="o">}</span>

        <span class="nx">updatedRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">updateRecord</span><span class="o">(</span><span class="nx">oldRecord</span><span class="o">,</span> <span class="nx">oData</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not update row &quot;</span> <span class="o">+</span> <span class="nx">row</span> <span class="o">+</span> <span class="s2">&quot; with the data : &quot;</span> <span class="o">+</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">dump</span><span class="o">(</span><span class="nx">oData</span><span class="o">),</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>

    <span class="o">}</span>
    
    <span class="c">// Update the TR only if row is on current page</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_updateTrEl</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">updatedRecord</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowUpdateEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">updatedRecord</span><span class="o">,</span> <span class="nx">oldData</span><span class="o">:</span><span class="nx">oldData</span><span class="o">});</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable row updated: Record ID = &quot;</span> <span class="o">+</span> <span class="nx">updatedRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">()</span> <span class="o">+</span>
            <span class="s2">&quot;, Record index = &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">updatedRecord</span><span class="o">)</span> <span class="o">+</span>
            <span class="s2">&quot;, page row index = &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">updatedRecord</span><span class="o">),</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Deletes the given row&#39;s Record from the RecordSet. If the row is on current page,</span>
<span class="c"> * the corresponding DOM elements are also deleted.</span>
<span class="c"> *</span>
<span class="c"> * @method deleteRow</span>
<span class="c"> * @param row {HTMLElement | String | Number} DOM element reference or ID string</span>
<span class="c"> * to DataTable page element or RecordSet index.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">deleteRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Get the Record index...</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="c">// ...by Record index</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// ...by element reference</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">sRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>
        
        <span class="c">// Remove from selection tracker if there</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">((</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">])</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">))</span> <span class="o">||</span>
                    <span class="o">((</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">recordId</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">)))</span> <span class="o">{</span>
                <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Copy data from the Record for the event that gets fired later</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">nRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">oRecordData</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">oData</span> <span class="o">=</span> <span class="o">{};</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">param</span> <span class="k">in</span> <span class="nx">oRecordData</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oData</span><span class="o">[</span><span class="nx">param</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oRecordData</span><span class="o">[</span><span class="nx">param</span><span class="o">];</span>
        <span class="o">}</span>

        <span class="c">// Grab the TR index before deleting the Record</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">nTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>

        <span class="c">// Delete Record from RecordSet</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">deleteRecord</span><span class="o">(</span><span class="nx">nRecordIndex</span><span class="o">);</span>

        <span class="c">// If row is on current page, delete the TR element</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">isLast</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nTrIndex</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">getLastTrEl</span><span class="o">().</span><span class="nx">sectionRowIndex</span><span class="o">)</span> <span class="o">?</span>
                    <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_deleteTrEl</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">);</span>

            <span class="c">// Empty body</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="c">// Update UI</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="c">// Set FIRST/LAST</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nTrIndex</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_setFirstRow</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">isLast</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_setLastRow</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="c">// Set EVEN/ODD</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nTrIndex</span> <span class="o">!=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_setRowStripes</span><span class="o">(</span><span class="nx">nTrIndex</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowDeleteEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">recordIndex</span><span class="o">:</span><span class="nx">nRecordIndex</span><span class="o">,</span>
                <span class="nx">oldData</span><span class="o">:</span><span class="nx">oData</span><span class="o">,</span> <span class="nx">trElIndex</span><span class="o">:</span><span class="nx">nTrIndex</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable row deleted: Record ID = &quot;</span> <span class="o">+</span> <span class="nx">sRecordId</span> <span class="o">+</span>
                <span class="s2">&quot;, Record index = &quot;</span> <span class="o">+</span> <span class="nx">nRecordIndex</span> <span class="o">+</span>
                <span class="s2">&quot;, page row index = &quot;</span> <span class="o">+</span> <span class="nx">nTrIndex</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not delete row: &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Convenience method to delete multiple rows.</span>
<span class="c"> *</span>
<span class="c"> * @method deleteRows</span>
<span class="c"> * @param row {HTMLElement | String | Number} DOM element reference or ID string</span>
<span class="c"> * to DataTable page element or RecordSet index.</span>
<span class="c"> * @param count {Number} (optional) How many rows to delete. A negative value</span>
<span class="c"> * will delete towards the beginning.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">deleteRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">,</span> <span class="nx">count</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Get the Record index...</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">nRecordIndex</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="c">// ...by Record index</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">nRecordIndex</span> <span class="o">=</span> <span class="nx">row</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="c">// ...by element reference</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">nRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">nRecordIndex</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">count</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">count</span><span class="o">))</span> <span class="o">{</span>
            <span class="c">// Start with highest index and work down</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">startIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">count</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">?</span> <span class="nx">nRecordIndex</span> <span class="o">+</span> <span class="nx">count</span> <span class="o">-</span><span class="m">1</span> <span class="o">:</span> <span class="nx">nRecordIndex</span><span class="o">;</span>
            <span class="k">var</span> <span class="nx">endIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">count</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">?</span> <span class="nx">nRecordIndex</span> <span class="o">:</span> <span class="nx">nRecordIndex</span> <span class="o">+</span> <span class="nx">count</span> <span class="o">+</span> <span class="m">1</span><span class="o">;</span>
            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;</span><span class="nx">endIndex</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(</span><span class="nx">nRecordIndex</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not delete row &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>














































<span class="c">// CELL FUNCTIONS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Outputs markup into the given TD based on given Record.</span>
<span class="c"> *</span>
<span class="c"> * @method formatCell</span>
<span class="c"> * @param elCell {HTMLElement} TD Element.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} (Optional) Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} (Optional) Column instance.</span>
<span class="c"> * @return {HTML} Markup.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">formatCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(!(</span><span class="nx">oRecord</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(!(</span><span class="nx">oColumn</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Column</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">);</span>
    <span class="o">}</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">sKey</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">oData</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">sKey</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">fnFormatter</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">formatter</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">switch</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">formatter</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">case</span> <span class="s2">&quot;button&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatButton</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatCheckbox</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;currency&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatCurrency</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;date&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatDate</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;dropdown&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatDropdown</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;email&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatEmail</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;link&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatLink</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;number&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatNumber</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatRadio</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;text&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatText</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;textarea&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatTextarea</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;textbox&quot;</span><span class="o">:</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatTextbox</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;html&quot;</span><span class="o">:</span>
                    <span class="c">// This is the default</span>
<span class="c"></span>                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">default</span><span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not find formatter function \&quot;&quot;</span> <span class="o">+</span>
                            <span class="nx">oColumn</span><span class="o">.</span><span class="nx">formatter</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
                    <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isFunction</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">formatter</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">fnFormatter</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">formatter</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Apply special formatter</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">fnFormatter</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">fnFormatter</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">elCell</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">elCell</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">))</span> <span class="o">?</span> <span class="nx">oData</span><span class="o">.</span><span class="nx">toString</span><span class="o">()</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Add custom classNames</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">aCustomClasses</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">aCustomClasses</span> <span class="o">=</span> <span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">];</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">aCustomClasses</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">aCustomClasses</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aCustomClasses</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">aCustomClasses</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;yui-dt-col-&quot;</span><span class="o">+</span><span class="nx">sKey</span><span class="o">);</span>

        <span class="c">// Is editable?</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editor</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EDITABLE</span><span class="o">);</span>
        <span class="o">}</span>
        
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellFormatEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oColumn</span><span class="o">,</span> <span class="nx">key</span><span class="o">:</span><span class="nx">sKey</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elCell</span><span class="o">});</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not format cell &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>


<span class="c">/**</span>
<span class="c"> * Formats a BUTTON element.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatButton</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object | Boolean} Data value for the cell. By default, the value</span>
<span class="c"> * is what gets written to the BUTTON.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatButton</span><span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">sValue</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;Click&quot;</span><span class="o">;</span>
    <span class="c">//TODO: support YAHOO.widget.Button</span>
<span class="c"></span>    <span class="c">//if(YAHOO.widget.Button) {</span>
<span class="c"></span>    
    <span class="c">//}</span>
<span class="c"></span>    <span class="c">//else {</span>
<span class="c"></span>        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;button type=\&quot;button\&quot; class=\&quot;&quot;</span><span class="o">+</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BUTTON</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">sValue</span> <span class="o">+</span> <span class="s2">&quot;&lt;/button&gt;&quot;</span><span class="o">;</span>
    <span class="c">//}</span>
<span class="c"></span><span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats a CHECKBOX element.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatCheckbox</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object | Boolean} Data value for the cell. Can be a simple</span>
<span class="c"> * Boolean to indicate whether checkbox is checked or not. Can be object literal</span>
<span class="c"> * {checked:bBoolean, label:sLabel}. Other forms of oData require a custom</span>
<span class="c"> * formatter.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatCheckbox</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">bChecked</span> <span class="o">=</span> <span class="nx">oData</span><span class="o">;</span>
    <span class="nx">bChecked</span> <span class="o">=</span> <span class="o">(</span><span class="nx">bChecked</span><span class="o">)</span> <span class="o">?</span> <span class="s2">&quot; checked&quot;</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;input type=\&quot;checkbox\&quot;&quot;</span> <span class="o">+</span> <span class="nx">bChecked</span> <span class="o">+</span>
            <span class="s2">&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_CHECKBOX</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats currency. Default unit is USD.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatCurrency</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Number} Data value for the cell.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatCurrency</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oData</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">nAmount</span> <span class="o">=</span> <span class="nx">oData</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">markup</span><span class="o">;</span>

        <span class="c">// Round to the penny</span>
<span class="c"></span>        <span class="nx">nAmount</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">round</span><span class="o">(</span><span class="nx">nAmount</span><span class="o">*</span><span class="m">100</span><span class="o">)/</span><span class="m">100</span><span class="o">;</span>

        <span class="c">// Default currency is USD</span>
<span class="c"></span>        <span class="nx">markup</span> <span class="o">=</span> <span class="s2">&quot;$&quot;</span><span class="o">+</span><span class="nx">nAmount</span><span class="o">;</span>

        <span class="c">// Normalize digits</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">dotIndex</span> <span class="o">=</span> <span class="nx">markup</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s2">&quot;.&quot;</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">dotIndex</span> <span class="o">&lt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">markup</span> <span class="o">+=</span> <span class="s2">&quot;.00&quot;</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">while</span><span class="o">(</span><span class="nx">dotIndex</span> <span class="o">&gt;</span> <span class="nx">markup</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">3</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">markup</span> <span class="o">+=</span> <span class="s2">&quot;0&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">markup</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats JavaScript Dates.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatDate</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} Data value for the cell, or null.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatDate</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oDate</span> <span class="o">=</span> <span class="nx">oData</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oDate</span> <span class="k">instanceof</span> <span class="nb">Date</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oDate</span><span class="o">.</span><span class="nx">getMonth</span><span class="o">()+</span><span class="m">1</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="nx">oDate</span><span class="o">.</span><span class="nx">getDate</span><span class="o">()</span>  <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="nx">oDate</span><span class="o">.</span><span class="nx">getFullYear</span><span class="o">();</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats SELECT elements.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatDropdown</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} Data value for the cell, or null.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatDropdown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedValue</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">))</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">dropdownOptions</span><span class="o">))</span> <span class="o">?</span>
            <span class="nx">oColumn</span><span class="o">.</span><span class="nx">dropdownOptions</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">selectEl</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">collection</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;select&quot;</span><span class="o">);</span>
    
    <span class="c">// Create the form element only once, so we can attach the onChange listener</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">collection</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Create SELECT element</span>
<span class="c"></span>        <span class="nx">selectEl</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;select&quot;</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DROPDOWN</span><span class="o">);</span>
        <span class="nx">selectEl</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">);</span>

        <span class="c">// Add event listener</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">,</span><span class="s2">&quot;change&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_onDropdownChange</span><span class="o">,</span><span class="k">this</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="nx">selectEl</span> <span class="o">=</span> <span class="nx">collection</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

    <span class="c">// Update the form element</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">selectEl</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Clear out previous options</span>
<span class="c"></span>        <span class="nx">selectEl</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
        
        <span class="c">// We have options to populate</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">options</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Create OPTION elements</span>
<span class="c"></span>            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">options</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">option</span> <span class="o">=</span> <span class="nx">options</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="k">var</span> <span class="nx">optionEl</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">);</span>
                <span class="nx">optionEl</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">option</span><span class="o">.</span><span class="nx">value</span><span class="o">))</span> <span class="o">?</span>
                        <span class="nx">option</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">option</span><span class="o">;</span>
                <span class="nx">optionEl</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">option</span><span class="o">.</span><span class="nx">text</span><span class="o">))</span> <span class="o">?</span>
                        <span class="nx">option</span><span class="o">.</span><span class="nx">text</span> <span class="o">:</span> <span class="nx">option</span><span class="o">;</span>
                <span class="nx">optionEl</span> <span class="o">=</span> <span class="nx">selectEl</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">optionEl</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Selected value is our only option</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">selectEl</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;option value=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">selectedValue</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">selectedValue</span> <span class="o">+</span> <span class="s2">&quot;&lt;/option&gt;&quot;</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats emails.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatEmail</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} Data value for the cell, or null.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatEmail</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oData</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;a href=\&quot;mailto:&quot;</span> <span class="o">+</span> <span class="nx">oData</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">oData</span> <span class="o">+</span> <span class="s2">&quot;&lt;/a&gt;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats links.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatLink</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} Data value for the cell, or null.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatLink</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oData</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;a href=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">oData</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">oData</span> <span class="o">+</span> <span class="s2">&quot;&lt;/a&gt;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats numbers.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatNumber</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} Data value for the cell, or null.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatNumber</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">oData</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">oData</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oData</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats INPUT TYPE=RADIO elements.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatRadio</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} (Optional) Data value for the cell.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatRadio</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">bChecked</span> <span class="o">=</span> <span class="nx">oData</span><span class="o">;</span>
    <span class="nx">bChecked</span> <span class="o">=</span> <span class="o">(</span><span class="nx">bChecked</span><span class="o">)</span> <span class="o">?</span> <span class="s2">&quot; checked&quot;</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;input type=\&quot;radio\&quot;&quot;</span> <span class="o">+</span> <span class="nx">bChecked</span> <span class="o">+</span>
            <span class="s2">&quot; name=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getKey</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;-radio\&quot;&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_RADIO</span><span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats text strings.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatText</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} (Optional) Data value for the cell.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatText</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)))</span> <span class="o">?</span>
            <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="c">//TODO: move to util function</span>
<span class="c"></span>    <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">value</span><span class="o">.</span><span class="nx">toString</span><span class="o">().</span><span class="nx">replace</span><span class="o">(</span><span class="sr">/&amp;/g</span><span class="o">,</span> <span class="s2">&quot;&amp;#38;&quot;</span><span class="o">).</span><span class="nx">replace</span><span class="o">(</span><span class="sr">/&lt;/g</span><span class="o">,</span> <span class="s2">&quot;&amp;#60;&quot;</span><span class="o">).</span><span class="nx">replace</span><span class="o">(</span><span class="sr">/&gt;/g</span><span class="o">,</span> <span class="s2">&quot;&amp;#62;&quot;</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats TEXTAREA elements.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatTextarea</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} (Optional) Data value for the cell.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatTextarea</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)))</span> <span class="o">?</span>
            <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">markup</span> <span class="o">=</span> <span class="s2">&quot;&lt;textarea&gt;&quot;</span> <span class="o">+</span> <span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;&lt;/textarea&gt;&quot;</span><span class="o">;</span>
    <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">markup</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats INPUT TYPE=TEXT elements.</span>
<span class="c"> *</span>
<span class="c"> * @method DataTable.formatTextbox</span>
<span class="c"> * @param el {HTMLElement} The element to format with markup.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column instance.</span>
<span class="c"> * @param oData {Object} (Optional) Data value for the cell.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">formatTextbox</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">,</span> <span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)))</span> <span class="o">?</span>
            <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">markup</span> <span class="o">=</span> <span class="s2">&quot;&lt;input type=\&quot;text\&quot; value=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span><span class="o">;</span>
    <span class="nx">el</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">markup</span><span class="o">;</span>
<span class="o">};</span>
















































<span class="c">// PAGINATION</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Updates Paginator values in response to RecordSet changes and/or DOM events.</span>
<span class="c"> * Pass in all, a subset, or no values.</span>
<span class="c"> *</span>
<span class="c"> * @method updatePaginator</span>
<span class="c"> * @param oNewValues {Object} (Optional) Object literal of Paginator values, or</span>
<span class="c"> * a subset of Paginator values.</span>
<span class="c"> * @param {Object} Object literal of all Paginator values.</span>
<span class="c"> */</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">updatePaginator</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oNewValues</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Complete the set</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">oValidPaginator</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">nOrigCurrentPage</span> <span class="o">=</span> <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">currentPage</span><span class="o">;</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">param</span> <span class="k">in</span> <span class="nx">oNewValues</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">,</span> <span class="nx">param</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">oValidPaginator</span><span class="o">[</span><span class="nx">param</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oNewValues</span><span class="o">[</span><span class="nx">param</span><span class="o">];</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getLength</span><span class="o">();</span>
    <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">rowsThisPage</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">,</span> <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalRecords</span><span class="o">);</span>
    <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalPages</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">ceil</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalRecords</span> <span class="o">/</span> <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">rowsThisPage</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalPages</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalPages</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">currentPage</span> <span class="o">&gt;</span> <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalPages</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalPages</span> <span class="o">&lt;</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">currentPage</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">currentPage</span> <span class="o">=</span> <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">totalPages</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">currentPage</span> <span class="o">!==</span> <span class="nx">nOrigCurrentPage</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">startRecordIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">currentPage</span><span class="o">-</span><span class="m">1</span><span class="o">)*</span><span class="nx">oValidPaginator</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">;</span>
    <span class="o">}</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">,</span> <span class="nx">oValidPaginator</span><span class="o">);</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Displays given page of a paginated DataTable.</span>
<span class="c"> *</span>
<span class="c"> * @method showPage</span>
<span class="c"> * @param nPage {Number} Which page.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showPage</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">nPage</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Validate input</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nPage</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">nPage</span> <span class="o">&lt;</span> <span class="m">1</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">nPage</span> <span class="o">&gt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">totalPages</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">nPage</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">({</span><span class="nx">currentPage</span><span class="o">:</span><span class="nx">nPage</span><span class="o">});</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">refreshView</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Updates Paginator containers with markup. Override this method to customize pagination UI.</span>
<span class="c"> *</span>
<span class="c"> * @method formatPaginators</span>
<span class="c"> */</span>
 <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">formatPaginators</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">pag</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>

    <span class="c">// For Opera workaround</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">dropdownEnabled</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="c">// Links are enabled</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">pag</span><span class="o">.</span><span class="nx">pageLinks</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">pag</span><span class="o">.</span><span class="nx">links</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">formatPaginatorLinks</span><span class="o">(</span><span class="nx">pag</span><span class="o">.</span><span class="nx">links</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">pag</span><span class="o">.</span><span class="nx">currentPage</span><span class="o">,</span> <span class="nx">pag</span><span class="o">.</span><span class="nx">pageLinksStart</span><span class="o">,</span> <span class="nx">pag</span><span class="o">.</span><span class="nx">pageLinks</span><span class="o">,</span> <span class="nx">pag</span><span class="o">.</span><span class="nx">totalPages</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Dropdown is enabled</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">pag</span><span class="o">.</span><span class="nx">dropdowns</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
         <span class="k">if</span><span class="o">(</span><span class="nx">pag</span><span class="o">.</span><span class="nx">dropdownOptions</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">dropdownEnabled</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">formatPaginatorDropdown</span><span class="o">(</span><span class="nx">pag</span><span class="o">.</span><span class="nx">dropdowns</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">pag</span><span class="o">.</span><span class="nx">dropdownOptions</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">pag</span><span class="o">.</span><span class="nx">dropdowns</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// For Opera artifacting in dropdowns</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">dropdownEnabled</span> <span class="o">&amp;&amp;</span> <span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">().</span><span class="nx">indexOf</span><span class="o">(</span><span class="s2">&quot;opera&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
        <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">style</span> <span class="o">+=</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Paginators formatted&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Updates Paginator dropdown. If dropdown doesn&#39;t exist, the markup is created.</span>
<span class="c"> * Sets dropdown elements&#39;s &quot;selected&quot; value.</span>
<span class="c"> *</span>
<span class="c"> * @method formatPaginatorDropdown</span>
<span class="c"> * @param elDropdown {HTMLElement} The SELECT element.</span>
<span class="c"> * @param dropdownOptions {Object[]} OPTION values for display in the SELECT element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">formatPaginatorDropdown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elDropdown</span><span class="o">,</span> <span class="nx">dropdownOptions</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elDropdown</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elDropdown</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">==</span> <span class="nb">document</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// Clear OPTION elements</span>
<span class="c"></span>        <span class="k">while</span> <span class="o">(</span><span class="nx">elDropdown</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">elDropdown</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Create OPTION elements</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">dropdownOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">dropdownOption</span> <span class="o">=</span> <span class="nx">dropdownOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
            <span class="k">var</span> <span class="nx">optionEl</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">);</span>
            <span class="nx">optionEl</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">value</span><span class="o">))</span> <span class="o">?</span>
                    <span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">dropdownOption</span><span class="o">;</span>
            <span class="nx">optionEl</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">text</span><span class="o">))</span> <span class="o">?</span>
                    <span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">text</span> <span class="o">:</span> <span class="nx">dropdownOption</span><span class="o">;</span>
            <span class="nx">optionEl</span> <span class="o">=</span> <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">optionEl</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="k">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">options</span><span class="o">;</span>
        <span class="c">// Update dropdown&#39;s &quot;selected&quot; value</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">options</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">options</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">((</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;paginator&quot;</span><span class="o">).</span><span class="nx">rowsPerPage</span> <span class="o">+</span> <span class="s2">&quot;&quot;</span><span class="o">)</span> <span class="o">===</span> <span class="nx">options</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">value</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">options</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">selected</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Show the dropdown</span>
<span class="c"></span>        <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not update Paginator dropdown &quot;</span> <span class="o">+</span> <span class="nx">elDropdown</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Updates Paginator links container with markup.</span>
<span class="c"> *</span>
<span class="c"> * @method formatPaginatorLinks</span>
<span class="c"> * @param elContainer {HTMLElement} The link container element.</span>
<span class="c"> * @param nCurrentPage {Number} Current page.</span>
<span class="c"> * @param nPageLinksStart {Number} First page link to display.</span>
<span class="c"> * @param nPageLinksLength {Number} How many page links to display.</span>
<span class="c"> * @param nTotalPages {Number} Total number of pages.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">formatPaginatorLinks</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">,</span> <span class="nx">nCurrentPage</span><span class="o">,</span> <span class="nx">nPageLinksStart</span><span class="o">,</span> <span class="nx">nPageLinksLength</span><span class="o">,</span> <span class="nx">nTotalPages</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elContainer</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elContainer</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">==</span> <span class="nb">document</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nCurrentPage</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nPageLinksStart</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">nTotalPages</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// Set up markup for first/last/previous/next</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">bIsFirstPage</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nCurrentPage</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">bIsLastPage</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nCurrentPage</span> <span class="o">==</span> <span class="nx">nTotalPages</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">sFirstLinkMarkup</span> <span class="o">=</span> <span class="o">(</span><span class="nx">bIsFirstPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DISABLED</span> <span class="o">+</span>
                <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRST</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&amp;lt;&lt;/a&gt; &quot;</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">sPrevLinkMarkup</span> <span class="o">=</span> <span class="o">(</span><span class="nx">bIsFirstPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DISABLED</span> <span class="o">+</span>
                <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVIOUS</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVIOUS</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&lt;/a&gt; &quot;</span> <span class="o">;</span>
        <span class="k">var</span> <span class="nx">sNextLinkMarkup</span> <span class="o">=</span> <span class="o">(</span><span class="nx">bIsLastPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DISABLED</span> <span class="o">+</span>
                <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXT</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXT</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&lt;/a&gt; &quot;</span> <span class="o">;</span>
        <span class="k">var</span> <span class="nx">sLastLinkMarkup</span> <span class="o">=</span> <span class="o">(</span><span class="nx">bIsLastPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DISABLED</span> <span class="o">+</span>
                <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span> <span class="o">+</span>  <span class="s2">&quot;\&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LAST</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&amp;gt;&lt;/a&gt; &quot;</span><span class="o">;</span>

        <span class="c">// Start with first and previous</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sMarkup</span> <span class="o">=</span> <span class="nx">sFirstLinkMarkup</span> <span class="o">+</span> <span class="nx">sPrevLinkMarkup</span><span class="o">;</span>
        
        <span class="c">// Ok to show all links</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">nMaxLinks</span> <span class="o">=</span> <span class="nx">nTotalPages</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">nFirstLink</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">nLastLink</span> <span class="o">=</span> <span class="nx">nTotalPages</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">nPageLinksLength</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Calculate how many links to show</span>
<span class="c"></span>            <span class="nx">nMaxLinks</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nPageLinksStart</span><span class="o">+</span><span class="nx">nPageLinksLength</span> <span class="o">&lt;</span> <span class="nx">nTotalPages</span><span class="o">)</span> <span class="o">?</span>
                    <span class="nx">nPageLinksStart</span><span class="o">+</span><span class="nx">nPageLinksLength</span><span class="o">-</span><span class="m">1</span> <span class="o">:</span> <span class="nx">nTotalPages</span><span class="o">;</span>

            <span class="c">// Try to keep the current page in the middle</span>
<span class="c"></span>            <span class="nx">nFirstLink</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nCurrentPage</span> <span class="o">-</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">floor</span><span class="o">(</span><span class="nx">nMaxLinks</span><span class="sr">/2) &gt; 0) ? nCurrentPage - Math.floor(nMaxLinks/</span><span class="m">2</span><span class="o">)</span> <span class="o">:</span> <span class="m">1</span><span class="o">;</span>
            <span class="nx">nLastLink</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nCurrentPage</span> <span class="o">+</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">floor</span><span class="o">(</span><span class="nx">nMaxLinks</span><span class="sr">/2) &lt;= nTotalPages) ? nCurrentPage + Math.floor(nMaxLinks/</span><span class="m">2</span><span class="o">)</span> <span class="o">:</span> <span class="nx">nTotalPages</span><span class="o">;</span>

            <span class="c">// Keep the last link in range</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">nFirstLink</span> <span class="o">===</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">nLastLink</span> <span class="o">=</span> <span class="nx">nMaxLinks</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="c">// Keep the first link in range</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nLastLink</span> <span class="o">===</span> <span class="nx">nTotalPages</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">nFirstLink</span> <span class="o">=</span> <span class="nx">nTotalPages</span> <span class="o">-</span> <span class="nx">nMaxLinks</span> <span class="o">+</span> <span class="m">1</span><span class="o">;</span>
            <span class="o">}</span>

            <span class="c">// An even number of links can get funky</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">nLastLink</span> <span class="o">-</span> <span class="nx">nFirstLink</span> <span class="o">===</span> <span class="nx">nMaxLinks</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">nLastLink</span><span class="o">--;</span>
            <span class="o">}</span>
      <span class="o">}</span>
        
        <span class="c">// Generate markup for each page</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">nFirstLink</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nLastLink</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">i</span> <span class="o">!=</span> <span class="nx">nCurrentPage</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sMarkup</span> <span class="o">+=</span> <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">i</span> <span class="o">+</span> <span class="s2">&quot;&lt;/a&gt; &quot;</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">sMarkup</span> <span class="o">+=</span> <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">i</span> <span class="o">+</span> <span class="s2">&quot;&lt;/span&gt;&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="nx">sMarkup</span> <span class="o">+=</span> <span class="nx">sNextLinkMarkup</span> <span class="o">+</span> <span class="nx">sLastLinkMarkup</span><span class="o">;</span>
        <span class="nx">elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">sMarkup</span><span class="o">;</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not format Paginator links&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

















































<span class="c">// SELECTION/HIGHLIGHTING</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * ID string of last highlighted cell element</span>
<span class="c"> *</span>
<span class="c"> * @property _sLastHighlightedTdElId</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sLastHighlightedTdElId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ID string of last highlighted row element</span>
<span class="c"> *</span>
<span class="c"> * @property _sLastHighlightedTrElId</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sLastHighlightedTrElId</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Array to track row selections (by sRecordId) and/or cell selections</span>
<span class="c"> * (by {recordId:sRecordId, columnId:sColumnId})</span>
<span class="c"> *</span>
<span class="c"> * @property _aSelections</span>
<span class="c"> * @type Object[]</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Record instance of the row selection anchor.</span>
<span class="c"> *</span>
<span class="c"> * @property _oAnchorRecord</span>
<span class="c"> * @type YAHOO.widget.Record</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Object literal representing cell selection anchor:</span>
<span class="c"> * {recordId:sRecordId, columnId:sColumnId}.</span>
<span class="c"> *</span>
<span class="c"> * @property _oAnchorCell</span>
<span class="c"> * @type Object</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Convenience method to remove the class YAHOO.widget.DataTable.CLASS_SELECTED</span>
<span class="c"> * from all TR elements on the page.</span>
<span class="c"> *</span>
<span class="c"> * @method _unselectAllTrEls</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_unselectAllTrEls</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedRows</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">selectedRows</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns array of selected TR elements on the page.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedTrEls</span>
<span class="c"> * @return {HTMLElement[]} Array of selected TR elements.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedTrEls</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets given row to the selected state.</span>
<span class="c"> *</span>
<span class="c"> * @method selectRow</span>
<span class="c"> * @param row {HTMLElement | String | YAHOO.widget.Record | Number} HTML element</span>
<span class="c"> * reference or ID string, Record instance, or RecordSet position index.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">selectRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">elRow</span><span class="o">;</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">row</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
    <span class="o">}</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Update selection trackers</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
        <span class="k">var</span> <span class="nx">sRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

        <span class="c">// Remove if already there:</span>
<span class="c"></span>        <span class="c">// Use Array.indexOf if available...</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">sRecordId</span><span class="o">)</span> <span class="o">&gt;</span>  <span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">sRecordId</span><span class="o">),</span><span class="m">1</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// ...or do it the old-fashioned way</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
               <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">){</span>
                    <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Add to the end</span>
<span class="c"></span>        <span class="nx">tracker</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">sRecordId</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>

        <span class="c">// Update trackers</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Update UI</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowSelectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elRow</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Selected &quot;</span> <span class="o">+</span> <span class="nx">elRow</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not select &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>
<span class="c">// Backward compatibility</span>
<span class="c"></span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">select</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;The method select() has been deprecated&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; in favor of selectRow()&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">els</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">els</span> <span class="o">=</span> <span class="o">[</span><span class="nx">els</span><span class="o">];</span>
    <span class="o">}</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">els</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">els</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets given row to the selected state.</span>
<span class="c"> *</span>
<span class="c"> * @method selectRow</span>
<span class="c"> * @param row {HTMLElement | String | YAHOO.widget.Record | Number} HTML element</span>
<span class="c"> * reference or ID string, Record instance, or RecordSet position index.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselectRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">oRecord</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">row</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">row</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Update selection trackers</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
        <span class="k">var</span> <span class="nx">sRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

        <span class="c">// Remove if found</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">bFound</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
        <span class="c">// Use Array.indexOf if available...</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">sRecordId</span><span class="o">)</span> <span class="o">&gt;</span>  <span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">sRecordId</span><span class="o">),</span><span class="m">1</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// ...or do it the old-fashioned way</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
               <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">){</span>
                    <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        
        <span class="k">if</span><span class="o">(</span><span class="nx">bFound</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Update tracker</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>

            <span class="c">// Update the UI</span>
<span class="c"></span>            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowUnselectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elRow</span><span class="o">});</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unselected &quot;</span> <span class="o">+</span> <span class="nx">elRow</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>

            <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Update the UI</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowUnselectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elRow</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unselected &quot;</span> <span class="o">+</span> <span class="nx">elRow</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not unselect row &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Clears out all row selections.</span>
<span class="c"> *</span>
<span class="c"> * @method unselectAllRows</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselectAllRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">// Remove all rows from tracker</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
       <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">])){</span>
            <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Update tracker</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>

    <span class="c">// Update UI</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllTrEls</span><span class="o">();</span>

    <span class="c">//TODO: send an array of [{el:el,record:record}]</span>
<span class="c"></span>    <span class="c">//TODO: or convert this to an unselectRows method</span>
<span class="c"></span>    <span class="c">//TODO: that takes an array of rows or unselects all if none given</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;unselectAllRowsEvent&quot;</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unselected all rows&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Convenience method to remove the class YAHOO.widget.DataTable.CLASS_SELECTED</span>
<span class="c"> * from all TD elements in the internal tracker.</span>
<span class="c"> *</span>
<span class="c"> * @method _unselectAllTdEls</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_unselectAllTdEls</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedCells</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;td&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">selectedCells</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns array of selected TD elements on the page.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedTdEls</span>
<span class="c"> * @return {HTMLElement[]} Array of selected TD elements.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedTdEls</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;td&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets given cell to the selected state.</span>
<span class="c"> *</span>
<span class="c"> * @method selectCell</span>
<span class="c"> * @param cell {HTMLElement | String} DOM element reference or ID string</span>
<span class="c"> * to DataTable page element or RecordSet index.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">selectCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">cell</span><span class="o">)</span> <span class="o">{</span>
<span class="c">/*TODO:</span>
<span class="c">accept {record}</span>
<span class="c">*/</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">cell</span><span class="o">);</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">sColumnId</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span> <span class="o">&amp;&amp;</span> <span class="nx">sColumnId</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Get Record ID</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
            <span class="k">var</span> <span class="nx">sRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

            <span class="c">// Remove if there</span>
<span class="c"></span>            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
               <span class="k">if</span><span class="o">((</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">recordId</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">columnId</span> <span class="o">===</span> <span class="nx">sColumnId</span><span class="o">)){</span>
                    <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>

            <span class="c">// Add to the end</span>
<span class="c"></span>            <span class="nx">tracker</span><span class="o">.</span><span class="nx">push</span><span class="o">({</span><span class="nx">recordId</span><span class="o">:</span><span class="nx">sRecordId</span><span class="o">,</span> <span class="nx">columnId</span><span class="o">:</span><span class="nx">sColumnId</span><span class="o">});</span>

            <span class="c">// Update trackers</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">sColumnId</span><span class="o">)};</span>
            <span class="o">}</span>

            <span class="c">// Update the UI</span>
<span class="c"></span>            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellSelectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">sColumnId</span><span class="o">),</span> <span class="nx">key</span><span class="o">:</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elCell</span><span class="o">});</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Selected &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not select &quot;</span> <span class="o">+</span> <span class="nx">cell</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets given cell to the unselected state.</span>
<span class="c"> *</span>
<span class="c"> * @method unselectCell</span>
<span class="c"> * @param cell {HTMLElement | String} DOM element reference or ID string</span>
<span class="c"> * to DataTable page element or RecordSet index.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselectCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">cell</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">cell</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">sColumnId</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span> <span class="o">&amp;&amp;</span> <span class="nx">sColumnId</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Get Record ID</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
            <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

            <span class="c">// Is it selected?</span>
<span class="c"></span>            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">((</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">recordId</span> <span class="o">===</span> <span class="nx">id</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">columnId</span> <span class="o">===</span> <span class="nx">sColumnId</span><span class="o">)){</span>
                    <span class="c">// Remove from tracker</span>
<span class="c"></span>                    <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
                    
                    <span class="c">// Update tracker</span>
<span class="c"></span>                    <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>

                    <span class="c">// Update the UI</span>
<span class="c"></span>                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellUnselectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">sColumnId</span><span class="o">),</span> <span class="nx">key</span><span class="o">:</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elCell</span><span class="o">});</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unselected &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
                    <span class="k">return</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not unselect &quot;</span> <span class="o">+</span> <span class="nx">cell</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Clears out all cell selections.</span>
<span class="c"> *</span>
<span class="c"> * @method unselectAllCells</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">// Remove all cells from tracker</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
       <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">){</span>
            <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Update tracker</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>

    <span class="c">// Update UI</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllTdEls</span><span class="o">();</span>
    
    <span class="c">//TODO: send data</span>
<span class="c"></span>    <span class="c">//TODO: or fire individual cellUnselectEvent</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;unselectAllCellsEvent&quot;</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unselected all cells&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns true if given item is selected, false otherwise.</span>
<span class="c"> *</span>
<span class="c"> * @method isSelected</span>
<span class="c"> * @param o {String | HTMLElement | YAHOO.widget.Record | Number</span>
<span class="c"> * {record:YAHOO.widget.Record, column:YAHOO.widget.Column} } TR or TD element by</span>
<span class="c"> * reference or ID string, a Record instance, a RecordSet position index,</span>
<span class="c"> * or an object literal representation</span>
<span class="c"> * of a cell.</span>
<span class="c"> * @return {Boolean} True if item is selected.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">isSelected</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">sRecordId</span><span class="o">,</span> <span class="nx">j</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span> <span class="o">&amp;&amp;</span> <span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Looking for a Record?</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">o</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">o</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sRecordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

                <span class="c">// Is it there?</span>
<span class="c"></span>                <span class="c">// Use Array.indexOf if available...</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">sRecordId</span><span class="o">)</span> <span class="o">&gt;</span>  <span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
                    <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="c">// ...or do it the old-fashioned way</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
                       <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">){</span>
                        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
                       <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Looking for a cell</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">record</span> <span class="o">&amp;&amp;</span> <span class="nx">o</span><span class="o">.</span><span class="nx">column</span><span class="o">){</span>
                <span class="nx">sRecordId</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">record</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>
                <span class="k">var</span> <span class="nx">sColumnId</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

                <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
                    <span class="k">if</span><span class="o">((</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">recordId</span> <span class="o">===</span> <span class="nx">sRecordId</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">columnId</span> <span class="o">===</span> <span class="nx">sColumnId</span><span class="o">)){</span>
                        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns selected rows as an array of Record IDs.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedRows</span>
<span class="c"> * @return {String[]} Array of selected rows by Record ID.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">aSelectedRows</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
       <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">])){</span>
            <span class="nx">aSelectedRows</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">return</span> <span class="nx">aSelectedRows</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns selected cells as an array of object literals:</span>
<span class="c"> *     {recordId:sRecordId, columnId:sColumnId}.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedCells</span>
<span class="c"> * @return {Object[]} Array of selected cells by Record ID and Column ID.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedCells</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">aSelectedCells</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span> <span class="o">||</span> <span class="o">[];</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
       <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="o">)){</span>
            <span class="nx">aSelectedCells</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">return</span> <span class="nx">aSelectedCells</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns last selected Record ID.</span>
<span class="c"> *</span>
<span class="c"> * @method getLastSelectedRecord</span>
<span class="c"> * @return {String} Record ID of last selected row.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getLastSelectedRecord</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
           <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">i</span><span class="o">])){</span>
                <span class="k">return</span> <span class="nx">tracker</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns last selected cell as an object literal:</span>
<span class="c"> *     {recordId:sRecordId, columnId:sColumnId}.</span>
<span class="c"> *</span>
<span class="c"> * @method getLastSelectedCell</span>
<span class="c"> * @return {Object} Object literal representation of a cell.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getLastSelectedCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelections</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
           <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">recordId</span> <span class="o">&amp;&amp;</span> <span class="nx">tracker</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">columnId</span><span class="o">){</span>
                <span class="k">return</span> <span class="nx">tracker</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Assigns the class YAHOO.widget.DataTable.CLASS_HIGHLIGHTED to the given row.</span>
<span class="c"> *</span>
<span class="c"> * @method highlightRow</span>
<span class="c"> * @param row {HTMLElement | String} DOM element reference or ID string.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">highlightRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Make sure previous row is unhighlighted</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sLastHighlightedTrElId</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sLastHighlightedTrElId</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_sLastHighlightedTrElId</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowHighlightEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elRow</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Highlighted &quot;</span> <span class="o">+</span> <span class="nx">elRow</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not highlight &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Removes the class YAHOO.widget.DataTable.CLASS_HIGHLIGHTED from the given row.</span>
<span class="c"> *</span>
<span class="c"> * @method unhighlightRow</span>
<span class="c"> * @param row {HTMLElement | String} DOM element reference or ID string.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unhighlightRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">row</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowUnhighlightEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elRow</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unhighlighted &quot;</span> <span class="o">+</span> <span class="nx">elRow</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not unhighlight &quot;</span> <span class="o">+</span> <span class="nx">row</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Assigns the class YAHOO.widget.DataTable.CLASS_HIGHLIGHTED to the given cell.</span>
<span class="c"> *</span>
<span class="c"> * @method highlightCell</span>
<span class="c"> * @param cell {HTMLElement | String} DOM element reference or ID string.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">highlightCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">cell</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">cell</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Make sure previous cell is unhighlighted</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sLastHighlightedTdElId</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sLastHighlightedTdElId</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span><span class="o">);</span>
        <span class="o">}</span>
        
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">sColumnId</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">;</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_sLastHighlightedTdElId</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellHighlightEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">sColumnId</span><span class="o">),</span> <span class="nx">key</span><span class="o">:</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elCell</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Highlighted &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not highlight &quot;</span> <span class="o">+</span> <span class="nx">cell</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Removes the class YAHOO.widget.DataTable.CLASS_HIGHLIGHTED from the given cell.</span>
<span class="c"> *</span>
<span class="c"> * @method unhighlightCell</span>
<span class="c"> * @param cell {HTMLElement | String} DOM element reference or ID string.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unhighlightCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">cell</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">cell</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHTED</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellUnhighlightEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">getColumnById</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnId</span><span class="o">),</span> <span class="nx">key</span><span class="o">:</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">,</span> <span class="nx">el</span><span class="o">:</span><span class="nx">elCell</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Unhighlighted &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not unhighlight &quot;</span> <span class="o">+</span> <span class="nx">cell</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>













































<span class="c">// INLINE EDITING</span>
<span class="c"></span>
<span class="c">/*TODO: for TAB handling</span>
<span class="c"> * Shows Cell Editor for next cell.</span>
<span class="c"> *</span>
<span class="c"> * @method editNextCell</span>
<span class="c"> * @param elCell {HTMLElement} Cell element from which to edit next cell.</span>
<span class="c"> */</span>
<span class="c">//YAHOO.widget.DataTable.prototype.editNextCell = function(elCell) {</span>
<span class="c">//};</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Shows Cell Editor for given cell.</span>
<span class="c"> *</span>
<span class="c"> * @method showCellEditor</span>
<span class="c"> * @param elCell {HTMLElement | String} Cell element to edit.</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} (Optional) Record instance.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} (Optional) Column instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">ownerDocument</span> <span class="o">===</span> <span class="nb">document</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(!</span><span class="nx">oRecord</span> <span class="o">||</span> <span class="o">!(</span><span class="nx">oRecord</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Record</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">oRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span> <span class="o">||</span> <span class="o">!(</span><span class="nx">oColumn</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Column</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">oCellEditor</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">;</span>
            
            <span class="c">// Clear previous Editor</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">cancelCellEditor</span><span class="o">();</span>
            <span class="o">}</span>

            <span class="c">// Editor not defined</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editor</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="o">}</span>
            
            <span class="c">// Update Editor values</span>
<span class="c"></span>            <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">cell</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">;</span>
            <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">record</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">;</span>
            <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">column</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">;</span>
            <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">validator</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span> <span class="o">&amp;&amp;</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isFunction</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">validator</span><span class="o">))</span> <span class="o">?</span>
                    <span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">validator</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
            <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>

            <span class="c">// Move Editor</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
            <span class="k">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getX</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
            <span class="k">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getY</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>

            <span class="c">// SF doesn&#39;t get xy for cells in scrolling table</span>
<span class="c"></span>            <span class="c">// when tbody display is set to block</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">x</span><span class="o">)</span> <span class="o">||</span> <span class="nb">isNaN</span><span class="o">(</span><span class="nx">y</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">x</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">offsetLeft</span> <span class="o">+</span> <span class="c">// cell pos relative to table</span>
<span class="c"></span>                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getX</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">)</span> <span class="o">-</span> <span class="c">// plus table pos relative to document</span>
<span class="c"></span>                        <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">scrollLeft</span><span class="o">;</span> <span class="c">// minus tbody scroll</span>
<span class="c"></span>                <span class="nx">y</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">offsetTop</span> <span class="o">+</span> <span class="c">// cell pos relative to table</span>
<span class="c"></span>                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getY</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">)</span> <span class="o">-</span> <span class="c">// plus table pos relative to document</span>
<span class="c"></span>                        <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">+</span> <span class="c">// minus tbody scroll</span>
<span class="c"></span>                        <span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span> <span class="c">// account for fixed headers</span>
<span class="c"></span>            <span class="o">}</span>
            
            <span class="nx">elContainer</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">x</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">;</span>
            <span class="nx">elContainer</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">top</span> <span class="o">=</span> <span class="nx">y</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">;</span>

            <span class="c">// Show Editor</span>
<span class="c"></span>            <span class="nx">elContainer</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
            
            <span class="c">// Render Editor markup</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">fnEditor</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editor</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">switch</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editor</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editCheckbox</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;date&quot;</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editDate</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;dropdown&quot;</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editDropdown</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editRadio</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;textarea&quot;</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editTextarea</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;textbox&quot;</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editTextbox</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">default</span><span class="o">:</span>
                        <span class="nx">fnEditor</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isFunction</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editor</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">fnEditor</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">editor</span><span class="o">;</span>
            <span class="o">}</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">fnEditor</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Create DOM input elements</span>
<span class="c"></span>                <span class="nx">fnEditor</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
                
                <span class="c">// Show Save/Cancel buttons</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span> <span class="o">||</span> <span class="o">!</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">disableBtns</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">showCellEditorBtns</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">);</span>
                <span class="o">}</span>

                <span class="c">// Hook to customize the UI</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeShowCellEditor</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">);</span>

                <span class="nx">oCellEditor</span><span class="o">.</span><span class="nx">isActive</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                
                <span class="c">//TODO: verify which args to pass</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorShowEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oCellEditor</span><span class="o">});</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Cell Editor shown for &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not show Cell Editor for &quot;</span> <span class="o">+</span> <span class="nx">elCell</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable abstract method to customize Cell Editor UI.</span>
<span class="c"> *</span>
<span class="c"> * @method doBeforeShowCellEditor</span>
<span class="c"> * @param oCellEditor {Object} Cell Editor object literal.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">doBeforeShowCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oCellEditor</span><span class="o">)</span> <span class="o">{</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Adds Save/Cancel buttons to Cell Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method showCellEditorBtns</span>
<span class="c"> * @param elContainer {HTMLElement} Cell Editor container.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showCellEditorBtns</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Buttons</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elBtnsDiv</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;div&quot;</span><span class="o">));</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elBtnsDiv</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BUTTON</span><span class="o">);</span>

    <span class="c">// Save button</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elSaveBtn</span> <span class="o">=</span> <span class="nx">elBtnsDiv</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;button&quot;</span><span class="o">));</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elSaveBtn</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DEFAULT</span><span class="o">);</span>
    <span class="nx">elSaveBtn</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;OK&quot;</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elSaveBtn</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">saveCellEditor</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

    <span class="c">// Cancel button</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elCancelBtn</span> <span class="o">=</span> <span class="nx">elBtnsDiv</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;button&quot;</span><span class="o">));</span>
    <span class="nx">elCancelBtn</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;Cancel&quot;</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elCancelBtn</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">cancelCellEditor</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Clears Cell Editor of all state and UI.</span>
<span class="c"> *</span>
<span class="c"> * @method resetCellEditor</span>
<span class="c"> */</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">resetCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
    <span class="nx">elContainer</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    <span class="nx">elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Saves Cell Editor input to Record.</span>
<span class="c"> *</span>
<span class="c"> * @method saveCellEditor</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">saveCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">//TODO: Copy the editor&#39;s values to pass to the event</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">newData</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">oldData</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>

        <span class="c">// Validate input data</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">validator</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">validator</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">newData</span><span class="o">,</span> <span class="nx">oldData</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">resetCellEditor</span><span class="o">();</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorRevertEvent&quot;</span><span class="o">,</span>
                        <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">,</span> <span class="nx">oldData</span><span class="o">:</span><span class="nx">oldData</span><span class="o">,</span> <span class="nx">newData</span><span class="o">:</span><span class="nx">newData</span><span class="o">});</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not save Cell Editor input due to invalid data &quot;</span> <span class="o">+</span>
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">dump</span><span class="o">(</span><span class="nx">newData</span><span class="o">),</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
                <span class="k">return</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Update the Record</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">updateKey</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span><span class="o">);</span>

        <span class="c">// Update the UI</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">formatCell</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">);</span>

        <span class="c">// Clear out the Cell Editor</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">resetCellEditor</span><span class="o">();</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorSaveEvent&quot;</span><span class="o">,</span>
                <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">,</span> <span class="nx">oldData</span><span class="o">:</span><span class="nx">oldData</span><span class="o">,</span> <span class="nx">newData</span><span class="o">:</span><span class="nx">newData</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Cell Editor input saved&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Cell Editor not active to save input&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Cancels Cell Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method cancelCellEditor</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">cancelCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">isActive</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">resetCellEditor</span><span class="o">();</span>
        <span class="c">//TODO: preserve values for the event?</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorCancelEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">editor</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Cell Editor input canceled&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Cell Editor not active to cancel input&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Enables CHECKBOX Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method editCheckbox</span>
<span class="c"> * @param oEditor {Object} Object literal representation of Editor values.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} Reference back to DataTable instance.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="c">//YAHOO.widget.DataTable.editCheckbox = function(elContainer, oRecord, oColumn, oEditor, oSelf) {</span>
<span class="c"></span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editCheckbox</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oEditor</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">aCheckedValues</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">aCheckedValues</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">aCheckedValues</span> <span class="o">=</span> <span class="o">[</span><span class="nx">aCheckedValues</span><span class="o">];</span>
    <span class="o">}</span>

    <span class="c">// Checkboxes</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">checkboxOptions</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">checkboxOptions</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">checkboxOptions</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">checkboxValue</span><span class="o">,</span> <span class="nx">checkboxId</span><span class="o">,</span> <span class="nx">elLabel</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">k</span><span class="o">;</span>
        <span class="c">// First create the checkbox buttons in an IE-friendly way</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">checkboxOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">checkboxValue</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">checkboxOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="k">label</span><span class="o">)</span> <span class="o">?</span>
                    <span class="nx">checkboxOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="k">label</span> <span class="o">:</span> <span class="nx">checkboxOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
            <span class="nx">checkboxId</span> <span class="o">=</span>  <span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-checkbox&quot;</span> <span class="o">+</span> <span class="nx">j</span><span class="o">;</span>
            <span class="nx">elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">+=</span> <span class="s2">&quot;&lt;input type=\&quot;checkbox\&quot;&quot;</span> <span class="o">+</span>
                    <span class="s2">&quot; name=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-checkbox\&quot;&quot;</span> <span class="o">+</span>
                    <span class="s2">&quot; value=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">checkboxValue</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span> <span class="o">+</span>
                    <span class="s2">&quot; id=\&quot;&quot;</span> <span class="o">+</span>  <span class="nx">checkboxId</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span><span class="o">;</span>
            <span class="c">// Then create the labels in an IE-friendly way</span>
<span class="c"></span>            <span class="nx">elLabel</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;label&quot;</span><span class="o">));</span>
            <span class="nx">elLabel</span><span class="o">.</span><span class="nx">htmlFor</span> <span class="o">=</span> <span class="nx">checkboxId</span><span class="o">;</span>
            <span class="nx">elLabel</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">checkboxValue</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">var</span> <span class="nx">aCheckboxEls</span> <span class="o">=</span> <span class="o">[];</span>
        <span class="k">var</span> <span class="nx">checkboxEl</span><span class="o">;</span>
        <span class="c">// Loop through checkboxes to check them</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">checkboxOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">checkboxEl</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-checkbox&quot;</span> <span class="o">+</span> <span class="nx">j</span><span class="o">);</span>
            <span class="nx">aCheckboxEls</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">checkboxEl</span><span class="o">);</span>
            <span class="k">for</span><span class="o">(</span><span class="nx">k</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">k</span><span class="o">&lt;</span><span class="nx">aCheckedValues</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">k</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">checkboxEl</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="nx">aCheckedValues</span><span class="o">[</span><span class="nx">k</span><span class="o">])</span> <span class="o">{</span>
                    <span class="nx">checkboxEl</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Focus the first checkbox</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">===</span><span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_focusEl</span><span class="o">(</span><span class="nx">checkboxEl</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Loop through checkboxes to assign click handlers</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">checkboxOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">checkboxEl</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-checkbox&quot;</span> <span class="o">+</span> <span class="nx">j</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">checkboxEl</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(){</span>
                <span class="k">var</span> <span class="nx">aNewValues</span> <span class="o">=</span> <span class="o">[];</span>
                <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">m</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">m</span><span class="o">&lt;</span><span class="nx">aCheckboxEls</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">m</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">aCheckboxEls</span><span class="o">[</span><span class="nx">m</span><span class="o">].</span><span class="nx">checked</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">aNewValues</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">aCheckboxEls</span><span class="o">[</span><span class="nx">m</span><span class="o">].</span><span class="nx">value</span><span class="o">);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">aNewValues</span><span class="o">;</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorUpdateEvent&quot;</span><span class="o">,{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
            <span class="o">});</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Enables Date Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method editDate</span>
<span class="c"> * @param oEditor {Object} Object literal representation of Editor values.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} Reference back to DataTable instance.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editDate</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oEditor</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>

    <span class="c">// Calendar widget</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Calendar</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">selectedValue</span> <span class="o">=</span> <span class="o">(</span><span class="nx">value</span><span class="o">.</span><span class="nx">getMonth</span><span class="o">()+</span><span class="m">1</span><span class="o">)+</span><span class="s2">&quot;/&quot;</span><span class="o">+</span><span class="nx">value</span><span class="o">.</span><span class="nx">getDate</span><span class="o">()+</span><span class="s2">&quot;/&quot;</span><span class="o">+</span><span class="nx">value</span><span class="o">.</span><span class="nx">getFullYear</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">calContainer</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;div&quot;</span><span class="o">));</span>
        <span class="nx">calContainer</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;-dateContainer&quot;</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">calendar</span> <span class="o">=</span>
                <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Calendar</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-col&quot;</span> <span class="o">+</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;-date&quot;</span><span class="o">,</span>
                <span class="nx">calContainer</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span>
                <span class="o">{</span><span class="nx">selected</span><span class="o">:</span><span class="nx">selectedValue</span><span class="o">,</span> <span class="nx">pagedate</span><span class="o">:</span><span class="nx">value</span><span class="o">});</span>
        <span class="nx">calendar</span><span class="o">.</span><span class="nx">render</span><span class="o">();</span>
        <span class="nx">calContainer</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">cssFloat</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>

        <span class="c">//var calFloatClearer = elContainer.appendChild(document.createElement(&quot;br&quot;));</span>
<span class="c"></span>        <span class="c">//calFloatClearer.style.clear = &quot;both&quot;;</span>
<span class="c"></span>        
        <span class="nx">calendar</span><span class="o">.</span><span class="nx">selectEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">args</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="o">(</span><span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">0</span><span class="o">][</span><span class="m">0</span><span class="o">],</span> <span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">0</span><span class="o">][</span><span class="m">1</span><span class="o">]-</span><span class="m">1</span><span class="o">,</span> <span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">0</span><span class="o">][</span><span class="m">2</span><span class="o">]);</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorUpdateEvent&quot;</span><span class="o">,{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
        <span class="o">});</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="c">//TODO;</span>
<span class="c"></span>    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Enables SELECT Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method editDropdown</span>
<span class="c"> * @param oEditor {Object} Object literal representation of Editor values.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} Reference back to DataTable instance.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editDropdown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oEditor</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>

    <span class="c">// Textbox</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elDropdown</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;select&quot;</span><span class="o">));</span>
    <span class="k">var</span> <span class="nx">dropdownOptions</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">dropdownOptions</span><span class="o">))</span> <span class="o">?</span>
            <span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">dropdownOptions</span> <span class="o">:</span> <span class="o">[];</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">dropdownOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">dropdownOption</span> <span class="o">=</span> <span class="nx">dropdownOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">elOption</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">);</span>
        <span class="nx">elOption</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">value</span><span class="o">))</span> <span class="o">?</span>
                <span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">dropdownOption</span><span class="o">;</span>
        <span class="nx">elOption</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">text</span><span class="o">))</span> <span class="o">?</span>
                <span class="nx">dropdownOption</span><span class="o">.</span><span class="nx">text</span> <span class="o">:</span> <span class="nx">dropdownOption</span><span class="o">;</span>
        <span class="nx">elOption</span> <span class="o">=</span> <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">elOption</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">value</span> <span class="o">===</span> <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">value</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elDropdown</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">selected</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    
    <span class="c">// Set up a listener on each check box to track the input value</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elDropdown</span><span class="o">,</span> <span class="s2">&quot;change&quot;</span><span class="o">,</span>
        <span class="k">function</span><span class="o">(){</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">elDropdown</span><span class="o">[</span><span class="nx">elDropdown</span><span class="o">.</span><span class="nx">selectedIndex</span><span class="o">].</span><span class="nx">value</span><span class="o">;</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorUpdateEvent&quot;</span><span class="o">,{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
    <span class="o">});</span>
            
    <span class="c">// Focus the dropdown</span>
<span class="c"></span>    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_focusEl</span><span class="o">(</span><span class="nx">elDropdown</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Enables INPUT TYPE=RADIO Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method editRadio</span>
<span class="c"> * @param oEditor {Object} Object literal representation of Editor values.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} Reference back to DataTable instance.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editRadio</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oEditor</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>

    <span class="c">// Radios</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">radioOptions</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">radioOptions</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">editorOptions</span><span class="o">.</span><span class="nx">radioOptions</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">radioValue</span><span class="o">,</span> <span class="nx">radioId</span><span class="o">,</span> <span class="nx">elLabel</span><span class="o">,</span> <span class="nx">j</span><span class="o">;</span>
        <span class="c">// First create the radio buttons in an IE-friendly way</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">radioOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">radioValue</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">radioOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="k">label</span><span class="o">)</span> <span class="o">?</span>
                    <span class="nx">radioOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="k">label</span> <span class="o">:</span> <span class="nx">radioOptions</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
            <span class="nx">radioId</span> <span class="o">=</span>  <span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-radio&quot;</span> <span class="o">+</span> <span class="nx">j</span><span class="o">;</span>
            <span class="nx">elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">+=</span> <span class="s2">&quot;&lt;input type=\&quot;radio\&quot;&quot;</span> <span class="o">+</span>
                    <span class="s2">&quot; name=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-radio\&quot;&quot;</span> <span class="o">+</span>
                    <span class="s2">&quot; value=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">radioValue</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span> <span class="o">+</span>
                    <span class="s2">&quot; id=\&quot;&quot;</span> <span class="o">+</span>  <span class="nx">radioId</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span><span class="o">;</span>
            <span class="c">// Then create the labels in an IE-friendly way</span>
<span class="c"></span>            <span class="nx">elLabel</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;label&quot;</span><span class="o">));</span>
            <span class="nx">elLabel</span><span class="o">.</span><span class="nx">htmlFor</span> <span class="o">=</span> <span class="nx">radioId</span><span class="o">;</span>
            <span class="nx">elLabel</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">radioValue</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="c">// Then check one, and assign click handlers</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">radioOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">radioEl</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;-editor-radio&quot;</span> <span class="o">+</span> <span class="nx">j</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">value</span> <span class="o">===</span> <span class="nx">radioEl</span><span class="o">.</span><span class="nx">value</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">radioEl</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_focusEl</span><span class="o">(</span><span class="nx">radioEl</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">radioEl</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span>
                <span class="k">function</span><span class="o">(){</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorUpdateEvent&quot;</span><span class="o">,{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
            <span class="o">});</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Enables TEXTAREA Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method editTextarea</span>
<span class="c"> * @param oEditor {Object} Object literal representation of Editor values.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} Reference back to DataTable instance.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editTextarea</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oEditor</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
   <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">);</span>

    <span class="c">// Textarea</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elTextarea</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;textarea&quot;</span><span class="o">));</span>
    <span class="nx">elTextarea</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">width</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">;</span> <span class="c">//(parseInt(elCell.offsetWidth,10)) + &quot;px&quot;;</span>
<span class="c"></span>    <span class="nx">elTextarea</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">height</span> <span class="o">=</span> <span class="s2">&quot;3em&quot;</span><span class="o">;</span> <span class="c">//(parseInt(elCell.offsetHeight,10)) + &quot;px&quot;;</span>
<span class="c"></span>    <span class="nx">elTextarea</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">value</span><span class="o">)</span> <span class="o">?</span> <span class="nx">value</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    
    <span class="c">// Set up a listener on each check box to track the input value</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTextarea</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(){</span>
        <span class="c">//TODO: set on a timeout</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">elTextarea</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorUpdateEvent&quot;</span><span class="o">,{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
    <span class="o">});</span>
    
    <span class="c">// Select the text</span>
<span class="c"></span>    <span class="nx">elTextarea</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
    <span class="nx">elTextarea</span><span class="o">.</span><span class="nx">select</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Enables INPUT TYPE=TEXT Editor.</span>
<span class="c"> *</span>
<span class="c"> * @method editTextbox</span>
<span class="c"> * @param oEditor {Object} Object literal representation of Editor values.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} Reference back to DataTable instance.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">editTextbox</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oEditor</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
   <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">oEditor</span><span class="o">.</span><span class="nx">container</span><span class="o">;</span>
   <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">))</span> <span class="o">?</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">getData</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

    <span class="c">// Textbox</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elTextbox</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;input&quot;</span><span class="o">));</span>
    <span class="nx">elTextbox</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="s2">&quot;text&quot;</span><span class="o">;</span>
    <span class="nx">elTextbox</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">width</span> <span class="o">=</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">;</span> <span class="c">//(parseInt(elCell.offsetWidth,10)) + &quot;px&quot;;</span>
<span class="c"></span>    <span class="c">//elTextbox.style.height = &quot;1em&quot;; //(parseInt(elCell.offsetHeight,10)) + &quot;px&quot;;</span>
<span class="c"></span>    <span class="nx">elTextbox</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="o">;</span>

    <span class="c">// Set up a listener on each textbox to track the input value</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTextbox</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(){</span>
        <span class="c">//TODO: set on a timeout</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">elTextbox</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorUpdateEvent&quot;</span><span class="o">,{</span><span class="nx">editor</span><span class="o">:</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oCellEditor</span><span class="o">});</span>
    <span class="o">});</span>

    <span class="c">// Select the text</span>
<span class="c"></span>    <span class="nx">elTextbox</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
    <span class="nx">elTextbox</span><span class="o">.</span><span class="nx">select</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/*</span>
<span class="c"> * Validates Editor input value to type Number, doing type conversion as</span>
<span class="c"> * necessary. A valid Number value is return, else the previous value is returned</span>
<span class="c"> * if input value does not validate.</span>
<span class="c"> * </span>
<span class="c"> *</span>
<span class="c"> * @method validateNumber</span>
<span class="c"> * @param oData {Object} Data to validate.</span>
<span class="c"> * @static</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">validateNumber</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">//Convert to number</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">number</span> <span class="o">=</span> <span class="nx">oData</span> <span class="o">*</span> <span class="m">1</span><span class="o">;</span>

    <span class="c">// Validate</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">number</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">number</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not validate data &quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">dump</span><span class="o">(</span><span class="nx">oData</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot; to type Number&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>






































<span class="c">// ABSTRACT METHODS</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Overridable method gives implementers a hook to access data before</span>
<span class="c"> * it gets added to RecordSet and rendered to the TBODY.</span>
<span class="c"> *</span>
<span class="c"> * @method doBeforeLoadData</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> * @return {Boolean} Return true to continue loading data into RecordSet and</span>
<span class="c"> * updating DataTable with new Records, false to cancel.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">doBeforeLoadData</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">};</span>































































<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public Custom Event Handlers</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to sort Column.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSortColumn</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSortColumn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
<span class="c">//TODO: support nested header column sorting</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">evt</span><span class="o">);</span>
    
    <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getThEl</span><span class="o">(</span><span class="nx">target</span><span class="o">)</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="nx">el</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortable</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">sortColumn</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Column for &quot;</span> <span class="o">+</span> <span class="nx">target</span> <span class="o">+</span> <span class="s2">&quot; not sortable&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not find Column for &quot;</span> <span class="o">+</span> <span class="nx">target</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to manage selection according to desktop paradigm.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSelectRow</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSelectRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">sMode</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectionMode&quot;</span><span class="o">);</span>
    <span class="k">if</span> <span class="o">((</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;singlecell&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">bSHIFT</span> <span class="o">=</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">bCTRL</span> <span class="o">=</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">ctrlKey</span> <span class="o">||</span> <span class="o">((</span><span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">().</span><span class="nx">indexOf</span><span class="o">(</span><span class="s2">&quot;mac&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">metaKey</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
    <span class="c">//var nAnchorPos;</span>
<span class="c"></span>
    <span class="c">// Validate target row</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elTargetRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elTargetRow</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">nAnchorRecordIndex</span><span class="o">,</span> <span class="nx">nAnchorTrIndex</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">oTargetRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elTargetRow</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">nTargetRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">nTargetTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">elTargetRow</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">oAnchorRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">nAnchorRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">getFirstTrEl</span><span class="o">()))</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">getLastTrEl</span><span class="o">());</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Both SHIFT and CTRL</span>
<span class="c"></span>        <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;single&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bSHIFT</span> <span class="o">&amp;&amp;</span> <span class="nx">bCTRL</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Validate anchor</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">))</span> <span class="o">{</span>
                    <span class="c">// Select all rows between anchor row and target row, including target row</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorRecordIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetRecordIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">i</span><span class="o">))</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Select all rows between target row and anchor row, including target row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorRecordIndex</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">nTargetRecordIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">i</span><span class="o">))</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="c">// Unselect all rows between anchor row and target row</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorRecordIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetRecordIndex</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">i</span><span class="o">))</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">unselectRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Unselect all rows between target row and anchor row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetRecordIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nAnchorRecordIndex</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">i</span><span class="o">))</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">unselectRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Select the target row</span>
<span class="c"></span>                    <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Invalid anchor</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="c">// Set anchor</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oTargetRecord</span><span class="o">;</span>

                <span class="c">// Toggle selection of target</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">))</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">unselectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Only SHIFT</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;single&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bSHIFT</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>

            <span class="c">// Validate anchor</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Select all rows between anchor row and target row,</span>
<span class="c"></span>                <span class="c">// including the anchor row and target row</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorRecordIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetRecordIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Select all rows between target row and anchor row,</span>
<span class="c"></span>                <span class="c">// including the target row and anchor row</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorRecordIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">nTargetRecordIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Invalid anchor</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="c">// Set anchor</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oTargetRecord</span><span class="o">;</span>

                <span class="c">// Select target row only</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Only CTRL</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;single&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bCTRL</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Set anchor</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oTargetRecord</span><span class="o">;</span>

            <span class="c">// Toggle selection of target</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">))</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">unselectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Neither SHIFT nor CTRL and &quot;single&quot; mode</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;single&quot;</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// Neither SHIFT nor CTRL</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="c">// Set anchor</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorRecord</span> <span class="o">=</span> <span class="nx">oTargetRecord</span><span class="o">;</span>

            <span class="c">// Select only target</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">selectRow</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Clear any selections that are a byproduct of the click or dblclick</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sel</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nb">window</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">)</span> <span class="o">{</span>
        	<span class="nx">sel</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">)</span> <span class="o">{</span>
        	<span class="nx">sel</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">selection</span><span class="o">)</span> <span class="o">{</span>
        	<span class="nx">sel</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">selection</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">sel</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">sel</span><span class="o">.</span><span class="nx">empty</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sel</span><span class="o">.</span><span class="nx">empty</span><span class="o">();</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">sel</span><span class="o">.</span><span class="nx">removeAllRanges</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sel</span><span class="o">.</span><span class="nx">removeAllRanges</span><span class="o">();</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sel</span><span class="o">.</span><span class="nx">collapse</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sel</span><span class="o">.</span><span class="nx">collapse</span><span class="o">();</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not select row &quot;</span> <span class="o">+</span> <span class="nx">elTarget</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to select cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSelectCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSelectCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">sMode</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectionMode&quot;</span><span class="o">);</span>
    <span class="k">if</span> <span class="o">((</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;standard&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;single&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">bSHIFT</span> <span class="o">=</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">bCTRL</span> <span class="o">=</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">ctrlKey</span>  <span class="o">||</span> <span class="o">((</span><span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">().</span><span class="nx">indexOf</span><span class="o">(</span><span class="s2">&quot;mac&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">metaKey</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">currentRow</span><span class="o">,</span> <span class="nx">startIndex</span><span class="o">,</span> <span class="nx">endIndex</span><span class="o">;</span>
    
    <span class="k">var</span> <span class="nx">elTargetCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elTargetCell</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">nAnchorRecordIndex</span><span class="o">,</span> <span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">oAnchorColumn</span><span class="o">,</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">;</span>
        
        <span class="k">var</span> <span class="nx">elTargetRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrEl</span><span class="o">(</span><span class="nx">elTargetCell</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
        
        <span class="k">var</span> <span class="nx">oTargetRecord</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elTargetRow</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">nTargetRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oTargetRecord</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">oTargetColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elTargetCell</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">nTargetColKeyIndex</span> <span class="o">=</span> <span class="nx">oTargetColumn</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">nTargetTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">elTargetRow</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">oTargetCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oTargetRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oTargetColumn</span><span class="o">};</span>

        <span class="k">var</span> <span class="nx">oAnchorRecord</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">)</span> <span class="o">?</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">.</span><span class="nx">record</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">nAnchorRecordIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="nx">oAnchorColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
            <span class="nx">nAnchorColKeyIndex</span> <span class="o">=</span> <span class="nx">oAnchorColumn</span><span class="o">.</span><span class="nx">getKeyIndex</span><span class="o">();</span>
            <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTrIndex</span><span class="o">(</span><span class="nx">oAnchorRecord</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">getFirstTrEl</span><span class="o">()))</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">nAnchorTrIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecordIndex</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">getLastTrEl</span><span class="o">());</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">var</span> <span class="nx">oAnchorCell</span> <span class="o">=</span> <span class="o">{</span><span class="nx">record</span><span class="o">:</span><span class="nx">oAnchorRecord</span><span class="o">,</span> <span class="nx">column</span><span class="o">:</span><span class="nx">oAnchorColumn</span><span class="o">};</span>

        <span class="c">// Both SHIFT and CTRL</span>
<span class="c"></span>        <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;singlecell&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bSHIFT</span> <span class="o">&amp;&amp;</span> <span class="nx">bCTRL</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Validate anchor</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oAnchorRecord</span> <span class="o">&amp;&amp;</span> <span class="nx">oAnchorColumn</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Anchor is selected</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span><span class="o">))</span> <span class="o">{</span>
                    <span class="c">// All cells are on the same row</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">===</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select all cells between anchor cell and target cell, including target cell</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="c">// Select all cells between target cell and anchor cell, including target cell</span>
<span class="c"></span>                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTargetColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nAnchorColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Anchor row is above target row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select all cells on anchor row from anchor cell to the end of the row</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nAnchorTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nAnchorTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                            
                            <span class="c">// Select all cells on all rows between anchor row and target row</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++){</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>

                            <span class="c">// Select all cells on target row from first cell to the target cell</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>
                            <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>
                            
                            <span class="c">// Select all cells from startIndex to endIndex on rows between anchor row and target row</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Anchor row is below target row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">)</span> <span class="o">{</span>
                            <span class="c">// Select all cells on target row from target cell to the end of the row</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>

                            <span class="c">// Select all cells on all rows between target row and anchor row</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetTrIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++){</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>

                            <span class="c">// Select all cells on anchor row from first cell to the anchor cell</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nAnchorColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nAnchorTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>
                            <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorTrIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>

                            <span class="c">// Select all cells from startIndex to endIndex on rows between target row and anchor row</span>
<span class="c"></span>                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&gt;=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">--)</span> <span class="o">{</span>
                                <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">&gt;=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">--)</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Anchor cell is unselected</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="c">// All cells are on the same row</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">===</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Unselect all cells between anchor cell and target cell</span>
<span class="c"></span>                        <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                        <span class="c">// Select all cells between target cell and anchor cell</span>
<span class="c"></span>                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTargetColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetColKeyIndex</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nAnchorColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Anchor row is above target row</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Unselect all cells from anchor cell to target cell</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">currentRow</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="c">// This is the anchor row, only unselect cells after the anchor cell</span>
<span class="c"></span>                                <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">===</span> <span class="nx">nAnchorTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&gt;</span><span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// This is the target row, only unelect cells before the target cell</span>
<span class="c"></span>                                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">===</span> <span class="nx">nTargetTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&lt;</span><span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// Unselect all cells on this row</span>
<span class="c"></span>                                <span class="k">else</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Anchor row is below target row</span>
<span class="c"></span>                    <span class="k">else</span> <span class="o">{</span>
                        <span class="c">// Unselect all cells from target cell to anchor cell</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">currentRow</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="c">// This is the target row, only unselect cells after the target cell</span>
<span class="c"></span>                                <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">==</span> <span class="nx">nTargetTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&gt;</span><span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// This is the anchor row, only unselect cells before the anchor cell</span>
<span class="c"></span>                                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">==</span> <span class="nx">nAnchorTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&lt;</span><span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// Unselect all cells on this row</span>
<span class="c"></span>                                <span class="k">else</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>

                    <span class="c">// Select the target cell</span>
<span class="c"></span>                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">elTargetCell</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Invalid anchor</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="c">// Set anchor</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="nx">oTargetCell</span><span class="o">;</span>

                <span class="c">// Toggle selection of target</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">))</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">);</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Only SHIFT</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;singlecell&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bSHIFT</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>

            <span class="c">// Validate anchor</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oAnchorCell</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// All cells are on the same row</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">===</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                    <span class="c">// Select all cells between anchor cell and target cell,</span>
<span class="c"></span>                    <span class="c">// including the anchor cell and target cell</span>
<span class="c"></span>                    <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="c">// Select all cells between target cell and anchor cell</span>
<span class="c"></span>                    <span class="c">// including the target cell and anchor cell</span>
<span class="c"></span>                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nTargetColKeyIndex</span> <span class="o">&lt;</span> <span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">nTargetTrIndex</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Anchor row is above target row</span>
<span class="c"></span>                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nAnchorRecordIndex</span> <span class="o">&lt;</span> <span class="nx">nTargetRecordIndex</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select all cells from anchor cell to target cell</span>
<span class="c"></span>                        <span class="c">// including the anchor cell and target cell</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">currentRow</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="c">// This is the anchor row, only select the anchor cell and after</span>
<span class="c"></span>                                <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">==</span> <span class="nx">nAnchorTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&gt;=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// This is the target row, only select the target cell and before</span>
<span class="c"></span>                                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">==</span> <span class="nx">nTargetTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&lt;=</span><span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// Select all cells on this row</span>
<span class="c"></span>                                <span class="k">else</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the cellblock from anchor cell to target cell</span>
<span class="c"></span>                        <span class="c">// including the anchor cell and the target cell</span>
<span class="c"></span>                        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>
                        <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>

                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="c">// Anchor row is below target row</span>
<span class="c"></span>                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellrange&quot;</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select all cells from target cell to anchor cell,</span>
<span class="c"></span>                        <span class="c">// including the target cell and anchor cell</span>
<span class="c"></span>                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">currentRow</span> <span class="o">=</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="c">// This is the target row, only select the target cell and after</span>
<span class="c"></span>                                <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">==</span> <span class="nx">nTargetTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&gt;=</span><span class="nx">nTargetColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// This is the anchor row, only select the anchor cell and before</span>
<span class="c"></span>                                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">==</span> <span class="nx">nAnchorTrIndex</span><span class="o">)</span> <span class="o">{</span>
                                    <span class="k">if</span><span class="o">(</span><span class="nx">j</span><span class="o">&lt;=</span><span class="nx">nAnchorColKeyIndex</span><span class="o">)</span> <span class="o">{</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                    <span class="o">}</span>
                                <span class="o">}</span>
                                <span class="c">// Select all cells on this row</span>
<span class="c"></span>                                <span class="k">else</span> <span class="o">{</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">currentRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sMode</span> <span class="o">==</span> <span class="s2">&quot;cellblock&quot;</span><span class="o">)</span> <span class="o">{</span>
                        <span class="c">// Select the cellblock from target cell to anchor cell</span>
<span class="c"></span>                        <span class="c">// including the target cell and the anchor cell</span>
<span class="c"></span>                        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">min</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>
                        <span class="nx">endIndex</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">nAnchorColKeyIndex</span><span class="o">,</span> <span class="nx">nTargetColKeyIndex</span><span class="o">);</span>

                        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">nTargetTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">nAnchorTrIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="k">for</span><span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">startIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;=</span><span class="nx">endIndex</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Invalid anchor</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="c">// Set anchor</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="nx">oTargetCell</span><span class="o">;</span>

                <span class="c">// Select target only</span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Only CTRL</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">((</span><span class="nx">sMode</span> <span class="o">!=</span> <span class="s2">&quot;singlecell&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bCTRL</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Set anchor</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="nx">oTargetCell</span><span class="o">;</span>

            <span class="c">// Toggle selection of target</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">))</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">unselectCell</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Neither SHIFT nor CTRL, or multi-selection has been disabled</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="c">// Set anchor</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_oAnchorCell</span> <span class="o">=</span> <span class="nx">oTargetCell</span><span class="o">;</span>

            <span class="c">// Select only target</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">selectCell</span><span class="o">(</span><span class="nx">oTargetCell</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Clear any selections that are a byproduct of the click or dblclick</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sel</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nb">window</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">)</span> <span class="o">{</span>
        	<span class="nx">sel</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">)</span> <span class="o">{</span>
        	<span class="nx">sel</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">getSelection</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">selection</span><span class="o">)</span> <span class="o">{</span>
        	<span class="nx">sel</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">selection</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">sel</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">sel</span><span class="o">.</span><span class="nx">empty</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sel</span><span class="o">.</span><span class="nx">empty</span><span class="o">();</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">sel</span><span class="o">.</span><span class="nx">removeAllRanges</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sel</span><span class="o">.</span><span class="nx">removeAllRanges</span><span class="o">();</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sel</span><span class="o">.</span><span class="nx">collapse</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sel</span><span class="o">.</span><span class="nx">collapse</span><span class="o">();</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not select cell &quot;</span> <span class="o">+</span> <span class="nx">elTarget</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>











<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to highlight row.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventHighlightRow</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventHighlightRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">highlightRow</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to unhighlight row.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventUnhighlightRow</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventUnhighlightRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">unhighlightRow</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to highlight cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventHighlightCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventHighlightCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">highlightCell</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to unhighlight cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventUnhighlightCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventUnhighlightCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">unhighlightCell</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to format cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventFormatCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventFormatCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">target</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span> <span class="o">&amp;&amp;</span> <span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getColumn</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">yuiColumnKey</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">formatCell</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">),</span> <span class="nx">oColumn</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not format cell &quot;</span> <span class="o">+</span> <span class="nx">target</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to edit cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventShowCellEditor</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventShowCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">target</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getTdEl</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showCellEditor</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not edit cell &quot;</span> <span class="o">+</span> <span class="nx">target</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>
<span class="c">// Backward compatibility</span>
<span class="c"></span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventEditCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;The method onEventEditCell() has been deprecated&quot;</span> <span class="o">+</span>
        <span class="s2">&quot; in favor of onEventShowCellEditor()&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">onEventShowCellEditor</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to save Cell Editor input.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSaveCellEditor</span>
<span class="c"> * @param oArgs.editor {Object} Cell Editor object literal.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSaveCellEditor</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">saveCellEditor</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Callback function for creating a progressively enhanced DataTable first</span>
<span class="c"> * receives data from DataSource and populates the RecordSet, then initializes</span>
<span class="c"> * DOM elements.</span>
<span class="c"> *</span>
<span class="c"> * @method _onDataReturnEnhanceTable</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> * @param bError {Boolean} (optional) True if there was a data error.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onDataReturnEnhanceTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Pass data through abstract method for any transformations</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>

    <span class="c">// Data ok to populate</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">// Update RecordSet</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">addRecords</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">);</span>

        <span class="c">// Initialize DOM elements</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_initTableEl</span><span class="o">();</span>
        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span> <span class="o">||</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elThead</span> <span class="o">||</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTbody</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid DOM elements&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
            <span class="k">return</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Call Element&#39;s constructor after DOM elements are created</span>
<span class="c"></span>        <span class="c">// but *before* UI is updated with data</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span><span class="o">);</span>

        <span class="c">//HACK: Set the Paginator values</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">updatePaginator</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oConfigs</span><span class="o">.</span><span class="nx">paginator</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="c">// Update the UI</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">refreshView</span><span class="o">();</span>
    <span class="o">}</span>
    <span class="c">// Error</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_ERROR</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ERROR</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Empty</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">){</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>
    
<span class="c">/**</span>
<span class="c"> * Callback function receives data from DataSource and populates an entire</span>
<span class="c"> * DataTable with Records and TR elements, clearing previous Records, if any.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnInitializeTable</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> * @param bError {Boolean} (optional) True if there was a data error.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnInitializeTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>

    <span class="c">// Pass data through abstract method for any transformations</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>

    <span class="c">// Data ok to populate</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">initializeTable</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Error</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_ERROR</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ERROR</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Empty</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">){</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>
<span class="c">// Backward compatibility</span>
<span class="c"></span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnReplaceRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;The method onDataReturnReplaceRows() has been deprecated&quot;</span> <span class="o">+</span>
            <span class="s2">&quot; in favor of onDataReturnInitializeTable()&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">onDataReturnInitializeTable</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Callback function receives data from DataSource and appends to an existing</span>
<span class="c"> * DataTable new Records and, if applicable, creates or updates</span>
<span class="c"> * corresponding TR elements.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnAppendRows</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> * @param bError {Boolean} (optional) True if there was a data error.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnAppendRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>
    
    <span class="c">// Pass data through abstract method for any transformations</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
    
    <span class="c">// Data ok to append</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">addRows</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Error</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_ERROR</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ERROR</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Callback function receives data from DataSource and inserts into top of an</span>
<span class="c"> * existing DataTable new Records and, if applicable, creates or updates</span>
<span class="c"> * corresponding TR elements.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnInsertRows</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> * @param bError {Boolean} (optional) True if there was a data error.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnInsertRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>
    
    <span class="c">// Pass data through abstract method for any transformations</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
    
    <span class="c">// Data ok to append</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">addRows</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">.</span><span class="nx">results</span><span class="o">,</span> <span class="m">0</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Error</span>
<span class="c"></span>    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">ok</span> <span class="o">&amp;&amp;</span> <span class="nx">oResponse</span><span class="o">.</span><span class="nx">error</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showTableMessage</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_ERROR</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ERROR</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>



































    <span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>    <span class="c">//</span>
<span class="c"></span>    <span class="c">// Custom Events</span>
<span class="c"></span>    <span class="c">//</span>
<span class="c"></span>    <span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable instance&#39;s initialization is complete.</span>
<span class="c">     *</span>
<span class="c">     * @event initEvent</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable&#39;s view is refreshed.</span>
<span class="c">     *</span>
<span class="c">     * @event refreshEvent</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when data is returned from DataSource but before it is consumed by</span>
<span class="c">     * DataTable.</span>
<span class="c">     *</span>
<span class="c">     * @event dataReturnEvent</span>
<span class="c">     * @param oArgs.request {String} Original request.</span>
<span class="c">     * @param oArgs.response {Object} Response object.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a focus.</span>
<span class="c">     *</span>
<span class="c">     * @event tableFocusEvent</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a blur.</span>
<span class="c">     *</span>
<span class="c">     * @event tableBlurEvent</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The DataTable&#39;s TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The DataTable&#39;s TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The DataTable&#39;s TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a click.</span>
<span class="c">     *</span>
<span class="c">     * @event tableClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The DataTable&#39;s TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable has a dblclick.</span>
<span class="c">     *</span>
<span class="c">     * @event tableDblclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The DataTable&#39;s TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a fixed scrolling DataTable has a scroll.</span>
<span class="c">     *</span>
<span class="c">     * @event tableScrollEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The DataTable&#39;s CONTAINER element (in IE)</span>
<span class="c">     * or the DataTable&#39;s TBODY element (everyone else).</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a message is shown in the DataTable&#39;s message element.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMsgShowEvent</span>
<span class="c">     * @param oArgs.html {String} The HTML displayed.</span>
<span class="c">     * @param oArgs.className {String} The className assigned.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when the DataTable&#39;s message element is hidden.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMsgHideEvent</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header row has a mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event headerRowMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header row has a mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event headerRowMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header row has a mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event headerRowMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header row has a click.</span>
<span class="c">     *</span>
<span class="c">     * @event headerRowClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header row has a dblclick.</span>
<span class="c">     *</span>
<span class="c">     * @event headerRowDblclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header cell has a mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event headerCellMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header cell has a mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event headerCellMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header cell has a mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event headerCellMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header cell has a click.</span>
<span class="c">     *</span>
<span class="c">     * @event headerCellClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header cell has a dblclick.</span>
<span class="c">     *</span>
<span class="c">     * @event headerCellDblclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header label has a mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event headerLabelMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The SPAN element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header label has a mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event headerLabelMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The SPAN element.</span>
<span class="c">     *</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header label has a mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event headerLabelMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The SPAN element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header label has a click.</span>
<span class="c">     *</span>
<span class="c">     * @event headerLabelClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The SPAN element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a header label has a dblclick.</span>
<span class="c">     *</span>
<span class="c">     * @event headerLabelDblclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The SPAN element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a column is sorted.</span>
<span class="c">     *</span>
<span class="c">     * @event columnSortEvent</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The Column instance.</span>
<span class="c">     * @param oArgs.dir {String} Sort direction &quot;asc&quot; or &quot;desc&quot;.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a column is resized.</span>
<span class="c">     *</span>
<span class="c">     * @event columnResizeEvent</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The Column instance.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row has a mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event rowMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row has a mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event rowMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row has a mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event rowMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row has a click.</span>
<span class="c">     *</span>
<span class="c">     * @event rowClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row has a dblclick.</span>
<span class="c">     *</span>
<span class="c">     * @event rowDblclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TR element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row is added.</span>
<span class="c">     *</span>
<span class="c">     * @event rowAddEvent</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The added Record.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row is updated.</span>
<span class="c">     *</span>
<span class="c">     * @event rowUpdateEvent</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The updated Record.</span>
<span class="c">     * @param oArgs.oldData {Object} Object literal of the old data.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row is deleted.</span>
<span class="c">     *</span>
<span class="c">     * @event rowDeleteEvent</span>
<span class="c">     * @param oArgs.oldData {Object} Object literal of the deleted data.</span>
<span class="c">     * @param oArgs.recordIndex {Number} Index of the deleted Record.</span>
<span class="c">     * @param oArgs.trElIndex {Number} Index of the deleted TR element, if on current page.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row is selected.</span>
<span class="c">     *</span>
<span class="c">     * @event rowSelectEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The selected TR element, if applicable.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The selected Record.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a row is unselected.</span>
<span class="c">     *</span>
<span class="c">     * @event rowUnselectEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The unselected TR element, if applicable.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The unselected Record.</span>
<span class="c">     */</span>

    <span class="c">/*TODO: delete and use rowUnselectEvent?</span>
<span class="c">     * Fired when all row selections are cleared.</span>
<span class="c">     *</span>
<span class="c">     * @event unselectAllRowsEvent</span>
<span class="c">     */</span>

    <span class="c">/*</span>
<span class="c">     * Fired when a row is highlighted.</span>
<span class="c">     *</span>
<span class="c">     * @event rowHighlightEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The highlighted TR element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The highlighted Record.</span>
<span class="c">     */</span>

    <span class="c">/*</span>
<span class="c">     * Fired when a row is unhighlighted.</span>
<span class="c">     *</span>
<span class="c">     * @event rowUnhighlightEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The highlighted TR element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The highlighted Record.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell has a mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event cellMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell has a mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event cellMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell has a mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event cellMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell has a click.</span>
<span class="c">     *</span>
<span class="c">     * @event cellClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell has a dblclick.</span>
<span class="c">     *</span>
<span class="c">     * @event cellDblclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell is formatted.</span>
<span class="c">     *</span>
<span class="c">     * @event cellFormatEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The formatted TD element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The associated Record instance.</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The associated Column instance.</span>
<span class="c">     * @param oArgs.key {String} (deprecated) The key of the formatted cell.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell is selected.</span>
<span class="c">     *</span>
<span class="c">     * @event cellSelectEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The selected TD element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The associated Record instance.</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The associated Column instance.</span>
<span class="c">     * @param oArgs.key {String} (deprecated) The key of the selected cell.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell is unselected.</span>
<span class="c">     *</span>
<span class="c">     * @event cellUnselectEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The unselected TD element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The associated Record.</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The associated Column instance.</span>
<span class="c">     * @param oArgs.key {String} (deprecated) The key of the unselected cell.</span>
<span class="c"></span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell is highlighted.</span>
<span class="c">     *</span>
<span class="c">     * @event cellHighlightEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The highlighted TD element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The associated Record instance.</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The associated Column instance.</span>
<span class="c">     * @param oArgs.key {String} (deprecated) The key of the highlighted cell.</span>
<span class="c"></span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a cell is unhighlighted.</span>
<span class="c">     *</span>
<span class="c">     * @event cellUnhighlightEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} The unhighlighted TD element.</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The associated Record instance.</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The associated Column instance.</span>
<span class="c">     * @param oArgs.key {String} (deprecated) The key of the unhighlighted cell.</span>
<span class="c"></span>
<span class="c">     */</span>

    <span class="c">/*TODO: hide from doc and use cellUnselectEvent</span>
<span class="c">     * Fired when all cell selections are cleared.</span>
<span class="c">     *</span>
<span class="c">     * @event unselectAllCellsEvent</span>
<span class="c">     */</span>

    <span class="c">/*TODO: implement</span>
<span class="c">     * Fired when DataTable paginator is updated.</span>
<span class="c">     *</span>
<span class="c">     * @event paginatorUpdateEvent</span>
<span class="c">     * @param paginator {Object} Object literal of Paginator values.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an Editor is activated.</span>
<span class="c">     *</span>
<span class="c">     * @event editorShowEvent</span>
<span class="c">     * @param oArgs.editor {Object} The Editor object literal.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an active Editor has a keydown.</span>
<span class="c">     *</span>
<span class="c">     * @event editorKeydownEvent</span>
<span class="c">     * @param oArgs.editor {Object} The Editor object literal.</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when Editor input is reverted.</span>
<span class="c">     *</span>
<span class="c">     * @event editorRevertEvent</span>
<span class="c">     * @param oArgs.editor {Object} The Editor object literal.</span>
<span class="c">     * @param oArgs.newData {Object} New data value.</span>
<span class="c">     * @param oArgs.oldData {Object} Old data value.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when Editor input is saved.</span>
<span class="c">     *</span>
<span class="c">     * @event editorSaveEvent</span>
<span class="c">     * @param oArgs.editor {Object} The Editor object literal.</span>
<span class="c">     * @param oArgs.newData {Object} New data value.</span>
<span class="c">     * @param oArgs.oldData {Object} Old data value.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when Editor input is canceled.</span>
<span class="c">     *</span>
<span class="c">     * @event editorCancelEvent</span>
<span class="c">     * @param oArgs.editor {Object} The Editor object literal.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an active Editor has a blur.</span>
<span class="c">     *</span>
<span class="c">     * @event editorBlurEvent</span>
<span class="c">     * @param oArgs.editor {Object} The Editor object literal.</span>
<span class="c">     */</span>







    <span class="c">/**</span>
<span class="c">     * Fired when a link is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event linkClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The A element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a BUTTON element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event buttonClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The BUTTON element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a CHECKBOX element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event checkboxClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The CHECKBOX element.</span>
<span class="c">     */</span>

    <span class="c">/*TODO</span>
<span class="c">     * Fired when a SELECT element is changed.</span>
<span class="c">     *</span>
<span class="c">     * @event dropdownChangeEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The SELECT element.</span>
<span class="c">     */</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a RADIO element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event radioClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The RADIO element.</span>
<span class="c">     */</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_colorpicker.html">colorpicker</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class="selected"><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_editor.html">editor</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_imageloader.html">imageloader</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>

                                <li class=""><a href="module_yuiloader.html">yuiloader</a></li>

                                <li class=""><a href="module_yuitest.html">yuitest</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.util.ColumnResizer.html">YAHOO.util.ColumnResizer</a></li>
                                <li class=""><a href="YAHOO.util.Sort.html">YAHOO.util.Sort</a></li>
                                <li class=""><a href="YAHOO.widget.Column.html">YAHOO.widget.Column</a></li>
                                <li class=""><a href="YAHOO.widget.ColumnSet.html">YAHOO.widget.ColumnSet</a></li>
                                <li class=""><a href="YAHOO.widget.DataTable.html">YAHOO.widget.DataTable</a></li>
                                <li class=""><a href="YAHOO.widget.Record.html">YAHOO.widget.Record</a></li>
                                <li class=""><a href="YAHOO.widget.RecordSet.html">YAHOO.widget.RecordSet</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="ColumnSet.js.html">ColumnSet.js</a></li>
                                <li class="selected"><a href="DataTable.js.html">DataTable.js</a></li>
                                <li class=""><a href="RecordSet.js.html">RecordSet.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
